[
https://issues.apache.org/jira/browse/FLINK-29758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17624293#comment-17624293
]
Alexandre Decuq commented on FLINK-29758:
-----------------------------------------
[~martijnvisser] Ok thanks for your quick answer :) so my idea will be to use
an user defined function to check if the string contains a value among a list
of values (like an enum).
> Serialization issue with enum
> -----------------------------
>
> Key: FLINK-29758
> URL: https://issues.apache.org/jira/browse/FLINK-29758
> Project: Flink
> Issue Type: Bug
> Components: API / Type Serialization System
> Affects Versions: 1.14.5
> Reporter: Alexandre Decuq
> Priority: Major
>
> Hello,
> I am implementing an SQL script between two Kafka topics (Avro).
> One field of my input is a STRING, the equivalent in output has been defined
> as ENUM.
> Here snaps of code:
> Avro input
> {code:java}
> {
> "name": "CompanyBankAccountMessage",
> "type": "record",
> "namespace": "com.kyriba.dataproduct.core.model.input",
> "fields": [
> {
> "default": null,
> "name": "ACCOUNT_TYPE",
> "type": [
> "null",
> "int"
> ]
> },
> ...
> },{code}
> Avro output
> {code:java}
> {
> "name": "Account",
> "type": "record",
> "namespace": "com.kyriba.dataproduct.core.model.output",
> "fields": [
> {
> "name": "type",
> "type": {
> "type": "enum",
> "name": "Type",
> "symbols": [
> "All",
> "Bank_account",
> "Intercompany_account",
> "Shared_account",
> "Other_account"
> ]
> }
> },
> ...
> ]
> }{code}
> My SQL looks like
> {code:java}
> INSERT INTO `my.output.account.v1.avro`
> SELECT BANK_ACCOUNT_TYPE type,
> ...
> FROM `my.input.COMPANY_BANK_ACCOUNT.v1.avro`{code}
> I got this exception:
> {code:java}
> Caused by: java.lang.RuntimeException: Failed to serialize row.
> at
> org.apache.flink.formats.avro.AvroRowDataSerializationSchema.serialize(AvroRowDataSerializationSchema.java:90)
> at
> com.kyriba.flink.datacatalog.formats.datacatalog.DataCatalogAvroRowDataSerializationSchema.serialize(DataCatalogAvroRowDataSerializationSchema.java:37)
> ...
> Caused by: org.apache.avro.AvroTypeException: value Bank_account (a
> org.apache.avro.util.Utf8) is not a Type at Account.type
> ...
> Caused by: org.apache.avro.AvroTypeException: value Bank_account (a
> org.apache.avro.util.Utf8) is not a Type {code}
> Did I make something wrong or this is a bug?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)