ebyhr commented on code in PR #15748:
URL: https://github.com/apache/iceberg/pull/15748#discussion_r2979083601


##########
core/src/test/java/org/apache/iceberg/TestFileGenerationUtil.java:
##########
@@ -85,6 +102,41 @@ public void testBoundsWithSpecificValues() {
     assertThat(actualIntUpper).isEqualTo(intUpper);
   }
 
+  @ParameterizedTest
+  @EnumSource(MetricsModeCase.class)
+  @SuppressWarnings("deprecation")
+  void testBoundsForAllMetricsModes(MetricsModeCase modeCase) {
+    MetricsConfig metricsConfig =
+        MetricsConfig.fromProperties(
+            ImmutableMap.of(TableProperties.DEFAULT_WRITE_METRICS_MODE, 
modeCase.modeName));
+    Metrics metrics =
+        FileGenerationUtil.generateRandomMetrics(
+            SCHEMA,
+            metricsConfig,
+            ImmutableMap.of() /* no lower bounds */,
+            ImmutableMap.of() /* no upper bounds */);
+
+    for (NestedField field : SCHEMA.columns()) {
+      ByteBuffer lower = metrics.lowerBounds().get(field.fieldId());
+      ByteBuffer upper = metrics.upperBounds().get(field.fieldId());
+      if (modeCase.hasBounds) {
+        assertThat(lower)
+            .as("lower bound for %s in mode %s", field.name(), 
modeCase.modeName)
+            .isNotNull();
+        assertThat(upper)
+            .as("upper bound for %s in mode %s", field.name(), 
modeCase.modeName)
+            .isNotNull();
+      } else {
+        assertThat(lower)
+            .as("lower bound for %s in mode %s", field.name(), 
modeCase.modeName)
+            .isNull();
+        assertThat(upper)
+            .as("upper bound for %s in mode %s", field.name(), 
modeCase.modeName)
+            .isNull();
+      }
+    }

Review Comment:
   Why not reuse the existing `checkBounds` helper method? 
   
   The `none` and `counts` fail without this PR's change as expected:
   
   ```java
     @ParameterizedTest
     @CsvSource({"none", "counts", "truncate(16)", "full"})
     @SuppressWarnings("deprecation")
     void testBoundsForAllMetricsModes(String metricsMode) {
       MetricsConfig metricsConfig =
           MetricsConfig.fromProperties(
               ImmutableMap.of(TableProperties.DEFAULT_WRITE_METRICS_MODE, 
metricsMode));
       Metrics metrics =
           FileGenerationUtil.generateRandomMetrics(
               SCHEMA,
               metricsConfig,
               ImmutableMap.of() /* no lower bounds */,
               ImmutableMap.of() /* no upper bounds */);
   
       checkBounds(metrics, metricsConfig);
     }
   ```



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