timothyw553 commented on code in PR #19079:
URL: https://github.com/apache/iceberg/pull/19079#discussion_r4708361353


##########
core/src/test/java/org/apache/iceberg/TestV4ManifestReader.java:
##########
@@ -2025,6 +2033,163 @@ public void readManifestLocations(FileFormat format) 
throws IOException {
     assertThat(locations).containsExactly(dataManifest.location(), 
deleteManifest.location());
   }
 
+  @ParameterizedTest
+  @FieldSource("MANIFEST_FORMATS")
+  void readGeoBounds(FileFormat format) throws IOException {
+    GeospatialBound lowerA = GeospatialBound.createXYZM(1.0, 2.0, 3.0, 4.0);
+    GeospatialBound upperA = GeospatialBound.createXYZM(5.0, 6.0, 7.0, 8.0);
+    GeospatialBound lowerB = GeospatialBound.createXY(-10.0, -20.0);
+    GeospatialBound upperB = GeospatialBound.createXY(30.0, 40.0);
+
+    OutputFile out =
+        writeTrackedFiles(
+            IO,
+            format,
+            UNPARTITIONED_TYPE,
+            GEOMETRY_STATS_TYPE,
+            ImmutableList.of(
+                geometryFile("s3://bucket/table/geo-a.parquet", lowerA, 
upperA),
+                geometryFile("s3://bucket/table/geo-b.parquet", lowerB, 
upperB)));
+
+    List<TrackedFile> files =
+        read(
+            V4ManifestReader.builder(
+                    v4Manifest(out.location()), IO, GEOMETRY_SCHEMA, 
UNPARTITIONED_SPECS)
+                .metricsConfig(GEOMETRY_METRICS_CONFIG));
+
+    assertThat(files).hasSize(2);
+    assertGeoBounds(files.get(0), lowerA, upperA);
+    assertGeoBounds(files.get(1), lowerB, upperB);
+  }
+
+  @ParameterizedTest
+  @FieldSource("MANIFEST_FORMATS")
+  void readGeoBoundProjectingOnlyM(FileFormat format) throws IOException {
+    GeospatialBound lower = GeospatialBound.createXYZM(1.0, 2.0, 3.0, 4.0);
+    GeospatialBound upper = GeospatialBound.createXYZM(5.0, 6.0, 7.0, 8.0);
+
+    OutputFile out =
+        writeTrackedFiles(
+            IO,
+            format,
+            UNPARTITIONED_TYPE,
+            GEOMETRY_STATS_TYPE,
+            ImmutableList.of(geometryFile("s3://bucket/table/geo.parquet", 
lower, upper)));
+
+    TrackedFile file =
+        readOne(
+            V4ManifestReader.builder(
+                    v4Manifest(out.location()), IO, GEOMETRY_SCHEMA, 
UNPARTITIONED_SPECS)
+                .metricsConfig(GEOMETRY_METRICS_CONFIG)
+                .select("content_stats.geom.lower_bound.m", 
"content_stats.geom.upper_bound.m"));
+
+    FieldStats<GeospatialBoundStruct> stats = file.contentStats().statsFor(1);
+    assertThat(stats.lowerBound().m()).isEqualTo(lower.m());
+    assertThat(stats.upperBound().m()).isEqualTo(upper.m());
+    assertThat(stats.lowerBound().z()).isNaN();
+    assertThatThrownBy(stats.lowerBound()::x)
+        .isInstanceOf(NullPointerException.class)
+        .hasMessageContaining("Double.doubleValue()");

Review Comment:
   nit: asserting on `Double.doubleValue()` ties the test to JVM-specific null 
unboxing wording. should we drop the message checks here?
   ```diff
    assertThatThrownBy(stats.lowerBound()::x)
   -    .isInstanceOf(NullPointerException.class)
   -    .hasMessageContaining("Double.doubleValue()");
   +    .isInstanceOf(NullPointerException.class);
    assertThatThrownBy(stats.lowerBound()::y)
   -    .isInstanceOf(NullPointerException.class)
   -    .hasMessageContaining("Double.doubleValue()");
   +    .isInstanceOf(NullPointerException.class);
   ```



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