Skip to content

Conversation

@fcote
Copy link

@fcote fcote commented Oct 30, 2025

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

Related to #294

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
@passuied
Copy link
Contributor

passuied commented Jan 1, 2026

@rockwotj could someone else review this PR? It is very useful IMHO

Copy link
Collaborator

@rockwotj rockwotj left a 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.
Copy link
Collaborator

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{
'"': '"',
Copy link
Collaborator

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.

Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants