Skip to content
Merged
Changes from all commits
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
Expand Up @@ -92,13 +92,13 @@ public Schema record(Schema record, List<String> names, Iterable<Schema.Field> s

if (avroField != null) {
// if the expectedField has a defaultValue, but the avroField does not, we need to
// create a newField to copy over the non-null default value
// create a newField to copy over the non-null default value.
if (expectedField.hasDefaultValue() && !AvroSchemaUtil.hasNonNullDefaultValue(avroField)) {
Schema newFiledSchema = (expectedField.isOptional()) ?
AvroSchemaUtil.toOption(AvroSchemaUtil.convert(expectedField.type()), true) :
AvroSchemaUtil.convert(expectedField.type());
AvroSchemaUtil.toOption(avroField.schema(), true) :
avroField.schema();
Schema.Field newField =
new Schema.Field(avroField.name(), newFiledSchema, avroField.doc(), expectedField.getDefaultValue());
new Schema.Field(avroField.name(), newFiledSchema, avroField.doc(), expectedField.getDefaultValue());
newField.addProp(AvroSchemaUtil.FIELD_ID_PROP, expectedField.fieldId());
updatedFields.add(newField);
hasChange = true;
Expand Down