DP-2782: Set struct field optionality in schema evolution #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a backport of @afiore's DP-2767 from Kafka EMS Connector 2.0
Background
When running some integration tests using schemaless JSON as input format, we observed a bug where the avro library was complaining due to a nested struct field being set to null (please refer to associated Jira ticket for more details on the failure scenario).
Root cause analysis and fix
The optional schema attribute was lost during the schema evolution, where we mistakenly forgot to set this field. The fix consists of a conditional statement where we set the schema to optional if either the left or the right term of the merge is optional.
Testing
StructSchemaEvolutionTest
suite where we add coverage for the log detailed above.