You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jark Wu (Jira)" <ji...@apache.org> on 2020/10/10 10:57:00 UTC
[jira] [Closed] (FLINK-19291) Fix exception for
AvroSchemaConverter#convertToSchema when RowType contains multiple row
fields
[ https://issues.apache.org/jira/browse/FLINK-19291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jark Wu closed FLINK-19291.
---------------------------
Fix Version/s: 1.12.0
Resolution: Fixed
Fixed in master: de87a2debde8546e6741390a81f43c032521c3c0
> Fix exception for AvroSchemaConverter#convertToSchema when RowType contains multiple row fields
> -----------------------------------------------------------------------------------------------
>
> Key: FLINK-19291
> URL: https://issues.apache.org/jira/browse/FLINK-19291
> Project: Flink
> Issue Type: Bug
> Components: Formats (JSON, Avro, Parquet, ORC, SequenceFile)
> Affects Versions: 1.11.0
> Reporter: xiaozilong
> Assignee: xiaozilong
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.12.0
>
> Attachments: image-2020-09-22-15-16-50-130.png
>
>
> Hi, I use `AvroSchemaConverter` to converts flink logical type into an avro schema will be throw `SchemaParseException` when there are multiple row type fields and the field names in each row type are different
>
> This is my simplified code
> {code:java}
> RowType rowType = (RowType) TableSchema.builder()
> .field("row1", DataTypes.ROW(DataTypes.FIELD("a", DataTypes.STRING())))
> .field("row2", DataTypes.ROW(DataTypes.FIELD("b", DataTypes.STRING())))
> .build().toRowDataType().getLogicalType();
> Schema schema = AvroSchemaConverter.convertToSchema(rowType);
> System.out.println(schema.toString(true));
> {code}
>
> it will throw
> {code:java}
> org.apache.avro.SchemaParseException: Can't redefine: row_1
> at org.apache.avro.Schema$Names.put(Schema.java:1128)
> at org.apache.avro.Schema$NamedSchema.writeNameRef(Schema.java:562)
> at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:690)
> at org.apache.avro.Schema$ArraySchema.toJson(Schema.java:805)
> at org.apache.avro.Schema$UnionSchema.toJson(Schema.java:882)
> at org.apache.avro.Schema$RecordSchema.fieldsToJson(Schema.java:716)
> at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:701)
> at org.apache.avro.Schema.toString(Schema.java:324)
> at org.apache.avro.Schema.toString(Schema.java:314)
> at java.lang.String.valueOf(String.java:2994)
> at java.io.PrintStream.println(PrintStream.java:821)
> at org.apache.flink.formats.avro.typeutils.AvroSchemaConverterTest.testRowTypeAvroSchemaConversion(AvroSchemaConverterTest.java:99)
> at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
> {code}
> Thanks!
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)