[ https://issues.apache.org/jira/browse/FLINK-19291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17199999#comment-17199999 ]
xiaozilong commented on FLINK-19291: ------------------------------------ Thanks for review this issue [~jark] , I think we can replace rowTypeCounter with fieldName, it works fine. Do you have any suggestions? !image-2020-09-22-15-16-50-130.png! > Meeting `SchemaParseException` when use `AvroSchemaConverter` converts flink > logical type > ----------------------------------------------------------------------------------------- > > 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 > 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 both row type and > row array type > > This is my simplified code > {code:java} > RowType rowType = (RowType) TableSchema.builder() > .field("row", DataTypes.ROW(DataTypes.FIELD("string_field", > DataTypes.STRING()))) > .field("row_array", > DataTypes.ARRAY(DataTypes.ROW(DataTypes.FIELD("string_field", > DataTypes.STRING())))) > .build().toRowDataType().getLogicalType(); > Schema schema = AvroSchemaConverter.convertToSchema(rowType); > System.out.println(schema); > {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)