pvary commented on code in PR #16280:
URL: https://github.com/apache/iceberg/pull/16280#discussion_r3388489098
##########
data/src/main/java/org/apache/iceberg/data/DeleteFilter.java:
##########
@@ -73,13 +72,19 @@ protected DeleteFilter(
Schema expectedSchema,
DeleteCounter counter,
boolean needRowPosCol) {
- this(filePath, deletes, tableSchema::findField, expectedSchema, counter,
needRowPosCol);
+ this(
+ filePath,
+ deletes,
+ ids -> TypeUtil.project(tableSchema, ids),
+ expectedSchema,
+ counter,
+ needRowPosCol);
}
protected DeleteFilter(
String filePath,
List<DeleteFile> deletes,
- Function<Integer, Types.NestedField> fieldLookup,
+ Function<Set<Integer>, Schema> missingSchemaResolver,
Review Comment:
What if we use something like this:
```
/**
* Resolves the field with the given ID within the schema. When the
field is nested inside one
* or more structs, the returned field is the top-level ancestor that
wraps the path down to
* the requested field so that the entire parent hierarchy is
preserved. Returns {@code null}
* if the schema does not contain the field.
*/
private static Types.NestedField projectField(Schema schema, int id) {
// top-level fields can be returned directly without rebuilding any
parent hierarchy
Types.NestedField topLevelField = schema.asStruct().field(id);
if (topLevelField != null) {
return topLevelField;
}
// skip projection unless the field is actually present somewhere in
the struct hierarchy
if (schema.findField(id) == null) {
return null;
}
// projecting a single nested field retains the chain of parent
structs that contain it
List<Types.NestedField> projected =
TypeUtil.project(schema, Collections.singleton(id)).columns();
return projected.isEmpty() ? null : projected.get(0);
}
```
--
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]