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


##########
core/src/test/java/org/apache/iceberg/TestMetricsConfig.java:
##########
@@ -28,18 +29,53 @@
 public class TestMetricsConfig {
 
   @Test
-  public void testNestedStructsRespectedInLimit() {
+  public void testNestedStruct() {
     Schema schema =
         new Schema(
             required(
-                1,
-                "col_struct",
+                11,
+                "level1_struct_a",
                 Types.StructType.of(
-                    required(2, "a", Types.IntegerType.get()),
-                    required(3, "b", Types.IntegerType.get()))),
-            required(4, "top", Types.IntegerType.get()));
+                    required(21, "level2_primitive_i", 
Types.IntegerType.get()),
+                    required(
+                        22,
+                        "level2_struct_a",
+                        Types.StructType.of(
+                            optional(31, "level3_primitive_s", 
Types.StringType.get()))),
+                    optional(23, "level2_primitive_b", 
Types.BooleanType.get()))),
+            required(
+                12,
+                "level1_struct_b",
+                Types.StructType.of(
+                    required(24, "level2_primitive_i", 
Types.IntegerType.get()),
+                    required(
+                        25,
+                        "level2_struct_b",
+                        Types.StructType.of(
+                            optional(32, "level3_primitive_s", 
Types.StringType.get()))))),
+            required(13, "level1_primitive_i", 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(13));
+    assertThat(MetricsConfig.limitFieldIds(schema, 2))
+        .as("Should include level 2 primitive field before nested struct")
+        .isEqualTo(Set.of(13, 21));
+    assertThat(MetricsConfig.limitFieldIds(schema, 3))
+        .as("Should include all of level 2 primitive fields of struct a before 
nested struct")
+        .isEqualTo(Set.of(13, 21, 23));
+    assertThat(MetricsConfig.limitFieldIds(schema, 4))
+        .as("Should include all eligible fields in struct a")
+        .isEqualTo(Set.of(13, 21, 23, 31));

Review Comment:
   I see. it is not completely breadth first. otherwise, field 24 should be 
included before 31



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