RussellSpitzer commented on a change in pull request #2952:
URL: https://github.com/apache/iceberg/pull/2952#discussion_r696178843



##########
File path: api/src/test/java/org/apache/iceberg/types/TestTypeUtil.java
##########
@@ -103,6 +105,267 @@ public void testAssignIncreasingFreshIdNewIdentifier() {
         Sets.newHashSet(sourceSchema.findField("a").fieldId()), 
actualSchema.identifierFieldIds());
   }
 
+  @Test
+  public void testProject() {
+    Schema schema = new Schema(
+        Lists.newArrayList(
+            required(10, "a", Types.IntegerType.get()),
+            required(11, "A", Types.IntegerType.get()),
+            required(12, "someStruct", Types.StructType.of(
+                required(13, "b", Types.IntegerType.get()),
+                required(14, "B", Types.IntegerType.get()),
+                required(15, "anotherStruct", Types.StructType.of(
+                    required(16, "c", Types.IntegerType.get()),
+                    required(17, "C", Types.IntegerType.get()))
+                )))));
+
+    Schema expectedTop = new Schema(
+        Lists.newArrayList(
+            required(11, "A", Types.IntegerType.get())));
+
+    Schema actualTop = TypeUtil.project(schema, Sets.newHashSet(11));
+    Assert.assertEquals(expectedTop.asStruct(), actualTop.asStruct());
+
+    Schema expectedDepthOne = new Schema(
+        Lists.newArrayList(
+            required(10, "a", Types.IntegerType.get()),
+            required(12, "someStruct", Types.StructType.of(
+                required(13, "b", Types.IntegerType.get())))));
+
+    Schema actualDepthOne = TypeUtil.project(schema, Sets.newHashSet(10, 12, 
13));
+    Assert.assertEquals(expectedDepthOne.asStruct(), 
actualDepthOne.asStruct());
+
+    Schema expectedDepthTwo = new Schema(
+        Lists.newArrayList(
+            required(11, "A", Types.IntegerType.get()),
+            required(12, "someStruct", Types.StructType.of(
+                required(15, "anotherStruct", Types.StructType.of(
+                    required(17, "C", Types.IntegerType.get()))
+                )))));
+
+    Schema actualDepthTwo = TypeUtil.project(schema, Sets.newHashSet(11, 12, 
15, 17));
+    Schema actualDepthTwoChildren = TypeUtil.project(schema, 
Sets.newHashSet(11, 17));

Review comment:
       Added another "Child only" projection here




-- 
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]

Reply via email to