huaxingao commented on code in PR #14847:
URL: https://github.com/apache/iceberg/pull/14847#discussion_r2648765333
##########
data/src/main/java/org/apache/iceberg/data/DeleteFilter.java:
##########
@@ -291,27 +297,37 @@ private static Schema fileProjection(
return requestedSchema;
}
- // TODO: support adding nested columns. this will currently fail when
finding nested columns to
- // add
- List<Types.NestedField> columns =
Lists.newArrayList(requestedSchema.columns());
+ // Build the schema preserving the requested schema's column order,
+ // then append missing fields, then metadata columns
+ List<Types.NestedField> columns = Lists.newArrayList();
+
+ // Add all columns from requested schema first (preserves order)
+ columns.addAll(requestedSchema.columns());
+
+ // Separate missing IDs into data and metadata columns
+ Set<Integer> missingDataIds = Sets.newLinkedHashSet();
+ Set<Integer> missingMetadataIds = Sets.newLinkedHashSet();
for (int fieldId : missingIds) {
- if (fieldId == MetadataColumns.ROW_POSITION.fieldId()
- || fieldId == MetadataColumns.IS_DELETED.fieldId()) {
- continue; // add _pos and _deleted at the end
+ if (MetadataColumns.isMetadataColumn(fieldId)) {
+ missingMetadataIds.add(fieldId);
+ } else {
+ missingDataIds.add(fieldId);
}
+ }
- Types.NestedField field = tableSchema.asStruct().field(fieldId);
+ // Add missing data columns from table schema
+ for (int fieldId : missingDataIds) {
+ Types.NestedField field = tableSchema.findField(fieldId);
Review Comment:
Does using `tableSchema.findField(fieldId)` here lose the nested structure?
--
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]