Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.linkedin.venice.spark.utils;

import com.linkedin.venice.hadoop.PushJobSetting;
import com.linkedin.venice.hadoop.exceptions.VeniceSchemaFieldNotFoundException;
import com.linkedin.venice.serializer.FastSerializerDeserializerFactory;
import com.linkedin.venice.serializer.RecordDeserializer;
import com.linkedin.venice.serializer.RecordSerializer;
Expand All @@ -26,7 +27,16 @@ public static Schema getInputRmdSchema(PushJobSetting pushJobSetting) {
throw new IllegalArgumentException(
"Push job setting missing rmd field. Please set the rmd field in the job properties.");
}
return pushJobSetting.inputDataSchema.getField(pushJobSetting.rmdField).schema();
Schema.Field rmdField = pushJobSetting.inputDataSchema.getField(pushJobSetting.rmdField);
if (rmdField == null) {
throw new VeniceSchemaFieldNotFoundException(
pushJobSetting.rmdField,
Comment thread
minhmo1620 marked this conversation as resolved.
"Could not find the configured timestamp.field '" + pushJobSetting.rmdField
+ "' at the top level of the push input record schema. The timestamp field must be a top-level field "
+ "of the input record (a sibling of the key and value fields), not nested inside the value. "
+ "Input record schema: " + pushJobSetting.inputDataSchema);
}
return rmdField.schema();
}

public static boolean containsLogicalTimestamp(PushJobSetting pushJobSetting) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.testng.Assert.assertTrue;

import com.linkedin.venice.hadoop.PushJobSetting;
import com.linkedin.venice.hadoop.exceptions.VeniceSchemaFieldNotFoundException;
import com.linkedin.venice.spark.utils.RmdPushUtils;
import org.apache.avro.Schema;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -35,6 +36,20 @@ public void testGetInputRmdSchemaWithNoRmdField() {
RmdPushUtils.getInputRmdSchema(pushJobSetting);
}

@Test(expectedExceptions = VeniceSchemaFieldNotFoundException.class)
public void testGetInputRmdSchemaWhenRmdFieldNotInInputSchema() {
// timestamp.field is configured, but the named field is absent from the top level of the input record schema
// (e.g. it is nested inside the value). getField returns null, so the call must fail with a clear error, not an
// NPE.
final String rmdField = "createdTimeEpoch";
Schema mockSchema = mock(Schema.class);
when(mockSchema.getField(eq(rmdField))).thenReturn(null);
PushJobSetting pushJobSetting = new PushJobSetting();
pushJobSetting.rmdField = rmdField;
pushJobSetting.inputDataSchema = mockSchema;
RmdPushUtils.getInputRmdSchema(pushJobSetting);
}

@Test
public void testContainsLogicalTimestamp() {
final String rmdField = "rmd";
Expand Down
Loading