jong-min-choi-5 opened a new pull request, #30216:
URL: https://github.com/apache/flink/pull/30216

   ## What is the purpose of the change
   
   Reading a topic whose Avro schema has an enum fails with the 
`avro-confluent` format:
   
   ```
   AvroTypeException: Found org.example.MyEnumType, expecting string
   ```
   
   (or `expecting union` for a nullable column)
   
   Flink SQL has no enum type, so the column is declared as `STRING` and the 
reader schema derived from the table has a string where the writer schema has 
an enum. Avro does not resolve an enum to a string.
   
   ## Brief change log
   
   - `RegistryAvroDeserializationSchema` can replace the strings of the reader 
schema with the enum that the writer schema declares in the same place 
(`readEnumAsString`). Fields and their order still come from the reader schema, 
so projection is not affected. The result is cached per writer schema.
   - `RegistryAvroFormatFactory` enables it for the `avro-confluent` format. 
The DataStream API behaves as before.
   
   Sinks and joins are not touched. `debezium-avro-confluent` derives its 
reader schema the same way and is left out of this PR.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - `RegistryAvroRowDataSeDeSchemaTest#testRowDataReadEnumAsString`: the 
record from the Jira ticket with the enum as a required, nullable, array, map 
and nested field, read by a table that declares a subset of the fields in a 
different order.
   - 
`RegistryAvroRowDataSeDeSchemaTest#testRowDataReadEnumAsStringWithEvolvedSchema`:
 records of two schema versions, the later one adding a symbol.
   - `RegistryAvroDeserializationSchemaTest#testGenericRecordReadEnumAsString`: 
still fails without the flag.
   - Ran `mvn verify` for `flink-avro` and `flink-avro-confluent-registry`.
   
   ## 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 (adds a constructor and a factory method to classes 
without an annotation)
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): yes, one map 
lookup per record in the `avro-confluent` source
   - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
   - 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 (please specify the tool below)
   
   Generated-by: Claude Code (Claude Fable 5.2)
   


-- 
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]

Reply via email to