Closed
Description
The following test will throw an exception when parsing the partition's Iceberg schema to Avro schema
Test: rdsr@95b95b0
The problem is that the Avro parser cannot handle dots in the field name and throws an exception
org.apache.avro.SchemaParseException: Illegal character in: a_struct.a_primitive
at org.apache.avro.Schema.validateName(Schema.java:1151)
at org.apache.avro.Schema.access$200(Schema.java:81)
at org.apache.avro.Schema$Field.<init>(Schema.java:403)
at org.apache.avro.Schema$Field.<init>(Schema.java:423)
at org.apache.avro.Schema$Field.<init>(Schema.java:415)
at org.apache.iceberg.avro.TypeToSchema.struct(TypeToSchema.java:91)
at org.apache.iceberg.avro.TypeToSchema.struct(TypeToSchema.java:33)
at org.apache.iceberg.types.TypeUtil.visit(TypeUtil.java:238)
at org.apache.iceberg.avro.AvroSchemaUtil.convert(AvroSchemaUtil.java:71)
at org.apache.iceberg.avro.AvroSchemaUtil.convert(AvroSchemaUtil.java:67)
at org.apache.iceberg.PartitionData.partitionDataSchema(PartitionData.java:42)
at org.apache.iceberg.PartitionData.<init>(PartitionData.java:71)
at org.apache.iceberg.TestPartitionData.testNestedField(TestPartitionData.java:16)
AFAICT from the spec nested fields are allowed for partitioning
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]`PartitionData` cannot handle nested field names in `PartitionSpec` schema[/-][+]PartitionData cannot handle nested field names in PartitionSpec schema[/+]rdsr commentedon Jun 14, 2019
@rdblue , as per the spec
So we can possibly have 2 ways to address this.
rdblue commentedon Jun 14, 2019
Iceberg supports special characters in names, looks like the failure is in Avro. I think Iceberg should sanitize special characters from the names when creating an Avro schema.
rdsr commentedon Jun 14, 2019
The special char can only be DOT though right?
Also it seems like you are suggesting that we should handle the sanitization in TypeToSchema visitor. That makes sense to me.
rdblue commentedon Jun 14, 2019
I think it could be anything since we allow users to pass strings into
UpdateSchema. We should probably sanitize any character that isn't allowed by Avro, assuming that they might creep in.By the way, because we project based on ID and not by name, the names used in Avro files don't really matter. So this should be safe to change.