-
Notifications
You must be signed in to change notification settings - Fork 229
Add SkipAdditionalFields codec option #300
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
base: master
Are you sure you want to change the base?
Conversation
Introduces a new CodecOption.SkipAdditionalFields that allows decoding
textual Avro data with additional fields not defined in the schema.
When enabled, unknown fields are skipped instead of causing errors.
This is useful for schema evolution scenarios where newer data formats
may include fields that older schemas don't define. The option defaults
to false to maintain backward compatibility.
Changes:
- Add SkipAdditionalFields field to CodecOption
- Update genericMapTextDecoder to skip unknown fields when enabled
- Add advanceToNextValue helper to skip JSON values
- Thread option through record and union decoders
|
@rockwotj could someone else review this PR? It is very useful IMHO |
rockwotj
left a comment
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.
there is a bug around escaped quotes
| // Primarily used to handle edge cases where some Avro implementations allow string representations of null. | ||
| EnableStringNull bool | ||
|
|
||
| // SkipAdditionalFields controls handling of additional fields during decoding. |
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.
This needs to mention it is for the textual format only.
|
|
||
| var ( | ||
| valueBoundaries = map[byte]byte{ | ||
| '"': '"', |
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.
this doesn’t account for escaped quotes.
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.
and maybe not for nested object/arrays? It just stops at the first thing it sees
Introduces a new
CodecOption.SkipAdditionalFieldsthat allows decoding textual Avro data with additional fields not defined in the schema. When enabled, unknown fields are skipped instead of causing errors.This is useful for schema evolution scenarios where newer data formats may include fields that older schemas don't define. The option defaults to
falseto maintain backward compatibility.Changes:
- Add
SkipAdditionalFieldsfield toCodecOption- Update
genericMapTextDecoderto skip unknown fields when enabled- Add
advanceToNextValuehelper to skip JSON valuesRelated to #294