-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISSUE-633 : Fix error when creating a schema with field that is nullable but with default value #636
Conversation
…able but with default value
|
||
for (Schema.Field field : fields) { | ||
Schema fieldSchema = field.schema(); | ||
// check for union | ||
|
||
boolean currentFieldTypeIsUnion = fieldSchema.getType() == Schema.Type.UNION; | ||
Object defaultValue = field.defaultVal(); | ||
if (currentFieldTypeIsUnion) { | ||
// check for the fields with in union | ||
// if it is union and first type is null then set default value as null | ||
if (fieldSchema.getTypes().get(0).getType() == Schema.Type.NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it assumed or guaranteed that null type comes first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extending the example given in the Issue
- If geoAddress is null at serializer side, what do you get on deserialization for geoAddress?
- If geoAddress is not set at all on serializer side, what do you get on deserialization for geoAddress?
Can you add unit tests around this?
…efaults correctly
@guruchai : I have test to check if avro schema resolver is taking defaults for unions |
LGTM.... |
…ble but with default value (#636) * ISSUE-633 : Fix error when creating a schema with field that is nullable but with default value * Add test cases to check schema registry is parsing the unions with defaults correctly
…ble but with default value (#636) * ISSUE-633 : Fix error when creating a schema with field that is nullable but with default value * Add test cases to check schema registry is parsing the unions with defaults correctly
…hat is nullable but with default value (#636) * ISSUE-633 : Fix error when creating a schema with field that is nullable but with default value * Add test cases to check schema registry is parsing the unions with defaults correctly
…hat is nullable but with default value (#636) * ISSUE-633 : Fix error when creating a schema with field that is nullable but with default value * Add test cases to check schema registry is parsing the unions with defaults correctly
…hat is nullable but with default value (#636) * ISSUE-633 : Fix error when creating a schema with field that is nullable but with default value * Add test cases to check schema registry is parsing the unions with defaults correctly
Fixes #633