szehon-ho commented on code in PR #4812:
URL: https://github.com/apache/iceberg/pull/4812#discussion_r940562715
##########
core/src/main/java/org/apache/iceberg/MetadataColumns.java:
##########
@@ -89,8 +92,15 @@ private MetadataColumns() {}
ROW_POSITION.fieldId(),
IS_DELETED.fieldId(),
SPEC_ID.fieldId(),
- PARTITION_COLUMN_ID);
+ PARTITION_COLUMN_ID,
Review Comment:
This is to avoid an issue when trying to read these new constant columns via
Avro reader, which is supported but only if they are defined in this set.
Note, we chose explicitly to not re-use the existing metadata column ids for
these constants, as it might cause confusion (metadata columns being a concept
for data tables).
```
Caused by: java.lang.IllegalArgumentException: Missing required field:
partition
at
org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:220)
at
org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:104)
at
org.apache.iceberg.avro.BuildAvroProjection.record(BuildAvroProjection.java:42)
at
org.apache.iceberg.avro.AvroCustomOrderSchemaVisitor.visit(AvroCustomOrderSchemaVisitor.java:50)
at
org.apache.iceberg.avro.AvroSchemaUtil.buildAvroProjection(AvroSchemaUtil.java:126)
at
org.apache.iceberg.avro.ProjectionDatumReader.setSchema(ProjectionDatumReader.java:68)
at
org.apache.avro.file.DataFileStream.initialize(DataFileStream.java:133)
at org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:139)
at org.apache.avro.file.DataFileReader.<init>(DataFileReader.java:131)
at
org.apache.avro.file.DataFileReader.openReader(DataFileReader.java:75)
at
org.apache.iceberg.avro.AvroIterable.newFileReader(AvroIterable.java:100)
at org.apache.iceberg.avro.AvroIterable.iterator(AvroIterable.java:76)
at
org.apache.iceberg.io.CloseableIterable.lambda$filter$0(CloseableIterable.java:110)
at
org.apache.iceberg.io.CloseableIterable$2.iterator(CloseableIterable.java:72)
at
org.apache.iceberg.spark.source.RowDataReader.open(RowDataReader.java:61)
at
org.apache.iceberg.spark.source.RowDataReader.open(RowDataReader.java:38)
at org.apache.iceberg.spark.source.BaseReader.next(BaseReader.java:128)
at
org.apache.spark.sql.execution.datasources.v2.PartitionIterator.hasNext(DataSourceRDD.scala:119)
at
org.apache.spark.sql.execution.datasources.v2.MetricsIterator.hasNext(DataSourceRDD.scala:156)
at
org.apache.spark.sql.execution.datasources.v2.DataSourceRDD$$anon$1.$anonfun$hasNext$1(DataSourceRDD.scala:63)
at
org.apache.spark.sql.execution.datasources.v2.DataSourceRDD$$anon$1.$anonfun$hasNext$1$adapted(DataSourceRDD.scala:63)
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]