Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhang10 committed Mar 11, 2024
1 parent aa412e4 commit 580d2eb
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private Schema reorderOptionIfRequired(Schema schema, Object defaultValue) {
boolean isNullFirstOption = schema.getTypes().get(0).getType() == Schema.Type.NULL;
if (isNullFirstOption && defaultValue.equals(JsonProperties.NULL_VALUE)) {
return schema;
} else if (!isNullFirstOption && !defaultValue.equals(JsonProperties.NULL_VALUE)) {
return schema;
} else {
return Schema.createUnion(schema.getTypes().get(1), schema.getTypes().get(0));
}
Expand Down Expand Up @@ -143,7 +145,7 @@ public Schema union(UnionTypeInfo union, Schema partner, List<Schema> results) {
@Override
public Schema primitive(PrimitiveTypeInfo primitive, Schema partner) {
boolean shouldResultBeOptional = partner == null || AvroSchemaUtil.isOptionSchema(partner);
boolean nullShouldBeSecondElementInOptionalUnionSchema =
boolean nullShouldBeSecondElementInOptionalUnionSchema = partner != null &&
shouldResultBeOptional && AvroSchemaUtil.getNullIndexInUnion(partner) == 1;
Schema hivePrimitive = hivePrimitiveToAvro(primitive);
// if there was no matching Avro primitive, use the Hive primitive
Expand Down

0 comments on commit 580d2eb

Please sign in to comment.