avi-sanwal opened a new pull request, #28161:
URL: https://github.com/apache/flink/pull/28161
## What is the purpose of the change
This pull request fixes GenericRecord Avro state migration when a compatible
schema evolution adds fields with defaults.
During state migration, Flink can deserialize old state bytes with the
previous GenericRecord schema and then serialize that value with the new
serializer. The migrated value is still shaped like the old schema, so writing
it directly with the new writer schema can fail in Avro's GenericDatumWriter
before Avro schema resolution applies defaults.
## Brief change log
- Resolve GenericRecord values whose embedded schema differs from the
serializer runtime schema before writing them.
- Keep the existing same-schema serialization path unchanged.
- Add a serializer snapshot regression test for old-schema read followed
by new-schema write.
## Verifying this change
This change added tests and can be verified as follows:
- Added
`AvroSerializerSnapshotTest#migratedGenericRecordShouldBeSerializedWithNewSchema`.
- Ran `./mvnw -pl flink-formats/flink-avro spotless:apply`.
- Ran `./mvnw -pl flink-formats/flink-avro
-Dtest=AvroSerializerSnapshotTest#migratedGenericRecordShouldBeSerializedWithNewSchema
-Dcheckstyle.skip -Drat.skip -Dspotless.check.skip test`; this did not reach
the test because the local Maven repository is missing required `2.4-SNAPSHOT`
Flink artifacts.
- Ran `./mvnw -pl flink-formats/flink-avro -am
-Dtest=AvroSerializerSnapshotTest#migratedGenericRecordShouldBeSerializedWithNewSchema
-DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
-Dcheckstyle.skip -Drat.skip -Dspotless.check.skip test`; this failed before
`flink-avro` in `flink-table-planner` Scala compilation due missing table
runtime type classes in this checkout.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: yes
- The runtime per-record code paths (performance sensitive): yes
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes, state
restore/migration
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes: OpenAI Codex GPT-5
Generated-by: OpenAI Codex GPT-5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]