szehon-ho commented on code in PR #10547: URL: https://github.com/apache/iceberg/pull/10547#discussion_r1663164870
########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScanBuilder.java: ########## @@ -375,30 +374,33 @@ private Schema schemaWithMetadataColumns() { .distinct() .map(name -> MetadataColumns.metadataColumn(table, name)) .collect(Collectors.toList()); - // only calculate potential column id collision if _partition was requested - Schema metadataSchema = - metadataFields.isEmpty() || !metaColumns.contains(MetadataColumns.PARTITION_COLUMN_NAME) - ? new Schema(metadataFields) - : deduplicateSchemaIds(metadataFields); + Schema metadataSchema = calculateMetadataSchema(metadataFields); // schema or rows returned by readers return TypeUtil.join(schema, metadataSchema); } - private Schema deduplicateSchemaIds(List<Types.NestedField> metaColumnFields) { - Map<Integer, Types.NestedField> indexedMetadataColumnFields = - TypeUtil.indexById(Types.StructType.of(metaColumnFields)); + private Schema calculateMetadataSchema(List<Types.NestedField> metaColumnFields) { + // only calculate potential column id collision if _partition was requested + boolean requireDeduplicateSchemaIds = Review Comment: Nit: how about just combine this and later logic here like ``` NestedField partitionField = metadataColumnFields.stream().filter(f -> MetadataCoolumns.Partition_COLUMN_ID == f.fieldId()); if (partitionField != null) { ... } return null; ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org