dramaticlly commented on code in PR #13785:
URL: https://github.com/apache/iceberg/pull/13785#discussion_r2279872897


##########
core/src/test/java/org/apache/iceberg/TestMetricsConfig.java:
##########
@@ -28,18 +29,47 @@
 public class TestMetricsConfig {
 
   @Test
-  public void testNestedStructsRespectedInLimit() {
+  public void testNestedStruct() {
     Schema schema =
         new Schema(
             required(
                 1,
-                "col_struct",
+                "top_struct_a1",
                 Types.StructType.of(
-                    required(2, "a", Types.IntegerType.get()),
-                    required(3, "b", Types.IntegerType.get()))),
-            required(4, "top", Types.IntegerType.get()));
+                    required(2, "middle_b1", Types.IntegerType.get()),
+                    required(
+                        3,
+                        "middle_struct_b1",
+                        Types.StructType.of(optional(4, "bottom_c1", 
Types.StringType.get()))))),
+            required(
+                5,
+                "top_struct_a2",
+                Types.StructType.of(
+                    required(6, "middle_b2", Types.IntegerType.get()),
+                    required(
+                        7,
+                        "middle_struct_b2",
+                        Types.StructType.of(optional(8, "bottom_c2", 
Types.StringType.get()))))),
+            required(9, "top_a", Types.IntegerType.get()));
 
-    assertThat(MetricsConfig.limitFieldIds(schema, 1)).isEqualTo(Set.of(4));
+    assertThat(MetricsConfig.limitFieldIds(schema, 1))
+        .as("Should only include top level primitive field")
+        .isEqualTo(Set.of(9));
+    assertThat(MetricsConfig.limitFieldIds(schema, 2))
+        .as("Should include next level primitive field before nested struct")
+        .isEqualTo(Set.of(9, 2));
+    assertThat(MetricsConfig.limitFieldIds(schema, 3))
+        .as("Should include all eligible fields of first struct before 
evaluate second struct")
+        .isEqualTo(Set.of(9, 2, 4));

Review Comment:
   This highlight the preorder traversal (9,2,4( and how is different from 
breadth first (9,2,7)



##########
core/src/test/java/org/apache/iceberg/TestMetricsConfig.java:
##########
@@ -28,18 +29,47 @@
 public class TestMetricsConfig {
 
   @Test
-  public void testNestedStructsRespectedInLimit() {
+  public void testNestedStruct() {
     Schema schema =
         new Schema(
             required(
                 1,
-                "col_struct",
+                "top_struct_a1",
                 Types.StructType.of(
-                    required(2, "a", Types.IntegerType.get()),
-                    required(3, "b", Types.IntegerType.get()))),
-            required(4, "top", Types.IntegerType.get()));
+                    required(2, "middle_b1", Types.IntegerType.get()),
+                    required(
+                        3,
+                        "middle_struct_b1",
+                        Types.StructType.of(optional(4, "bottom_c1", 
Types.StringType.get()))))),
+            required(
+                5,
+                "top_struct_a2",
+                Types.StructType.of(
+                    required(6, "middle_b2", Types.IntegerType.get()),
+                    required(
+                        7,
+                        "middle_struct_b2",
+                        Types.StructType.of(optional(8, "bottom_c2", 
Types.StringType.get()))))),
+            required(9, "top_a", Types.IntegerType.get()));
 
-    assertThat(MetricsConfig.limitFieldIds(schema, 1)).isEqualTo(Set.of(4));
+    assertThat(MetricsConfig.limitFieldIds(schema, 1))
+        .as("Should only include top level primitive field")
+        .isEqualTo(Set.of(9));
+    assertThat(MetricsConfig.limitFieldIds(schema, 2))
+        .as("Should include next level primitive field before nested struct")
+        .isEqualTo(Set.of(9, 2));
+    assertThat(MetricsConfig.limitFieldIds(schema, 3))
+        .as("Should include all eligible fields of first struct before 
evaluate second struct")
+        .isEqualTo(Set.of(9, 2, 4));

Review Comment:
   This highlight the preorder traversal (9,2,4) and how is different from 
breadth first (9,2,7)



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