RussellSpitzer commented on a change in pull request #2953:
URL: https://github.com/apache/iceberg/pull/2953#discussion_r710301227
##########
File path: api/src/main/java/org/apache/iceberg/types/TypeUtil.java
##########
@@ -130,13 +130,13 @@ public static Schema select(Schema schema, Set<Integer>
fieldIds) {
public static Types.StructType selectNot(Types.StructType struct,
Set<Integer> fieldIds) {
Set<Integer> projectedIds = getIdsInternal(struct);
projectedIds.removeAll(fieldIds);
- return select(struct, projectedIds);
+ return project(struct, projectedIds);
Review comment:
Wrote up these test cases, i'll run the full test suite to make sure
this works with our other usages
```
Schema schema = new Schema(
Lists.newArrayList(
required(1, "id", Types.LongType.get()),
required(2, "location", Types.StructType.of(
required(3, "lat", Types.DoubleType.get()),
required(4, "long", Types.DoubleType.get())
))));
Schema expectedNoPrimitive = new Schema(
Lists.newArrayList(
required(2, "location", Types.StructType.of(
required(3, "lat", Types.DoubleType.get()),
required(4, "long", Types.DoubleType.get())
))));
Schema actualNoPrimitve = TypeUtil.selectNot(schema, Sets.newHashSet(1));
Assert.assertEquals(expectedNoPrimitive.asStruct(),
actualNoPrimitve.asStruct());
// Expected legacy behavior is to completely remove structs if their
elements are removed
Schema expectedNoStructElements = new Schema(required(1, "id",
Types.LongType.get()));
Schema actualNoStructElements = TypeUtil.selectNot(schema,
Sets.newHashSet(3, 4));
Assert.assertEquals(expectedNoStructElements.asStruct(),
actualNoStructElements.asStruct());
// Expected legacy behavior is to ignore selectNot on struct elements.
Schema actualNoStruct = TypeUtil.selectNot(schema, Sets.newHashSet(2));
Assert.assertEquals(schema.asStruct(), actualNoStruct.asStruct());
```
--
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]