This is an automated email from the ASF dual-hosted git repository.
stevenzwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new aae4f5919a API, Core: Revert reading geo bounds as GeospatialBound
(#18394) (#19070)
aae4f5919a is described below
commit aae4f5919a794e02ce906e4229c452a3f7663459
Author: Steven Zhen Wu <[email protected]>
AuthorDate: Fri Nov 20 16:04:01 2026 -0800
API, Core: Revert reading geo bounds as GeospatialBound (#18394) (#19070)
Revert "Core: Read geometry and geography bounds as GeospatialBound
(#18394)"
This reverts commit ea47af380c0bf41a64fac858d0d89d1227db0418.
---
.../apache/iceberg/geospatial/GeospatialBound.java | 37 +-----
.../iceberg/geospatial/TestGeospatialBound.java | 68 +----------
.../java/org/apache/iceberg/FieldStatsStruct.java | 7 +-
.../java/org/apache/iceberg/V4ManifestReader.java | 52 +--------
.../org/apache/iceberg/TestFieldStatsStruct.java | 54 +++------
.../org/apache/iceberg/TestV4ManifestReader.java | 129 +--------------------
6 files changed, 32 insertions(+), 315 deletions(-)
diff --git
a/api/src/main/java/org/apache/iceberg/geospatial/GeospatialBound.java
b/api/src/main/java/org/apache/iceberg/geospatial/GeospatialBound.java
index d5f14a1b19..cdb76ae3c4 100644
--- a/api/src/main/java/org/apache/iceberg/geospatial/GeospatialBound.java
+++ b/api/src/main/java/org/apache/iceberg/geospatial/GeospatialBound.java
@@ -18,7 +18,6 @@
*/
package org.apache.iceberg.geospatial;
-import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Objects;
@@ -46,7 +45,7 @@ import
org.apache.iceberg.relocated.com.google.common.base.Preconditions;
* <p>This class represents a lower or upper geospatial bound and handles
serialization and
* deserialization of these bounds to/from byte arrays, conforming to the
Iceberg specification.
*/
-public class GeospatialBound implements StructLike, Serializable {
+public class GeospatialBound implements StructLike {
/**
* Parses a geospatial bound from a byte buffer according to Iceberg spec.
*
@@ -206,20 +205,16 @@ public class GeospatialBound implements StructLike,
Serializable {
}
@SuppressWarnings("MemberName")
- private double x;
+ private final double x;
@SuppressWarnings("MemberName")
- private double y;
+ private final double y;
@SuppressWarnings("MemberName")
- private double z;
+ private final double z;
@SuppressWarnings("MemberName")
- private double m;
-
- private GeospatialBound() {
- this(Double.NaN, Double.NaN, Double.NaN, Double.NaN);
- }
+ private final double m;
/** Private constructor - use factory methods instead. */
@SuppressWarnings("ParameterName")
@@ -288,11 +283,6 @@ public class GeospatialBound implements StructLike,
Serializable {
return !Double.isNaN(m);
}
- /** Returns a new bound with the same coordinates. */
- public GeospatialBound copy() {
- return new GeospatialBound(x, y, z, m);
- }
-
@Override
public int size() {
return 4;
@@ -311,13 +301,7 @@ public class GeospatialBound implements StructLike,
Serializable {
@Override
public <T> void set(int pos, T value) {
- switch (pos) {
- case 0 -> this.x = requiredCoordinate("x", value);
- case 1 -> this.y = requiredCoordinate("y", value);
- case 2 -> this.z = optionalCoordinate(value);
- case 3 -> this.m = optionalCoordinate(value);
- default -> throw new IllegalArgumentException("Invalid position: " +
pos);
- }
+ throw new UnsupportedOperationException("GeospatialBound is read only");
}
@Override
@@ -359,13 +343,4 @@ public class GeospatialBound implements StructLike,
Serializable {
public int hashCode() {
return Objects.hash(x, y, z, m);
}
-
- private static double requiredCoordinate(String coordinate, Object value) {
- Preconditions.checkArgument(value != null, "Invalid %s coordinate: null",
coordinate);
- return (Double) value;
- }
-
- private static double optionalCoordinate(Object value) {
- return value == null ? Double.NaN : (Double) value;
- }
}
diff --git
a/api/src/test/java/org/apache/iceberg/geospatial/TestGeospatialBound.java
b/api/src/test/java/org/apache/iceberg/geospatial/TestGeospatialBound.java
index 86d823c603..7b60ddc38c 100644
--- a/api/src/test/java/org/apache/iceberg/geospatial/TestGeospatialBound.java
+++ b/api/src/test/java/org/apache/iceberg/geospatial/TestGeospatialBound.java
@@ -83,26 +83,6 @@ public class TestGeospatialBound {
assertThat(bound.get(3, Double.class)).isNull();
}
- @Test
- public void testStructLikeXYZ() {
- StructLike bound = GeospatialBound.createXYZ(1.0, 2.0, 3.0);
- assertThat(bound.size()).isEqualTo(4);
- assertThat(bound.get(0, Double.class)).isEqualTo(1.0);
- assertThat(bound.get(1, Double.class)).isEqualTo(2.0);
- assertThat(bound.get(2, Double.class)).isEqualTo(3.0);
- assertThat(bound.get(3, Double.class)).isNull();
- }
-
- @Test
- public void testStructLikeXYM() {
- StructLike bound = GeospatialBound.createXYM(1.0, 2.0, 4.0);
- assertThat(bound.size()).isEqualTo(4);
- assertThat(bound.get(0, Double.class)).isEqualTo(1.0);
- assertThat(bound.get(1, Double.class)).isEqualTo(2.0);
- assertThat(bound.get(2, Double.class)).isNull();
- assertThat(bound.get(3, Double.class)).isEqualTo(4.0);
- }
-
@Test
public void testStructLikeXYZM() {
StructLike bound = GeospatialBound.createXYZM(3.0, 4.0, 5.0, 6.0);
@@ -116,51 +96,9 @@ public class TestGeospatialBound {
@Test
public void testSet() {
GeospatialBound bound = GeospatialBound.createXY(1.0, 2.0);
- bound.set(0, 9.0);
- bound.set(1, 8.0);
- // An XY bound still accepts z and m; set does not lock the dimensions it
was created with.
- bound.set(2, 7.0);
- bound.set(3, 6.0);
- assertThat(bound.get(0, Double.class)).isEqualTo(9.0);
- assertThat(bound.get(1, Double.class)).isEqualTo(8.0);
- assertThat(bound.get(2, Double.class)).isEqualTo(7.0);
- assertThat(bound.get(3, Double.class)).isEqualTo(6.0);
- assertThat(bound.x()).isEqualTo(9.0);
- assertThat(bound.y()).isEqualTo(8.0);
- assertThat(bound.z()).isEqualTo(7.0);
- assertThat(bound.m()).isEqualTo(6.0);
-
- bound.set(2, null);
- bound.set(3, null);
- assertThat(bound.get(2, Double.class)).isNull();
- assertThat(bound.get(3, Double.class)).isNull();
- assertThat(bound.hasZ()).isFalse();
- assertThat(bound.hasM()).isFalse();
- }
-
- @Test
- public void testSetRejectsNullRequiredCoordinate() {
- GeospatialBound bound = GeospatialBound.createXY(1.0, 2.0);
- assertThatThrownBy(() -> bound.set(0, null))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Invalid x coordinate: null");
- assertThatThrownBy(() -> bound.set(1, null))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Invalid y coordinate: null");
- }
-
- @Test
- public void testCopyXY() {
- GeospatialBound bound = GeospatialBound.createXY(1.0, 2.0);
- GeospatialBound copy = bound.copy();
- assertThat(copy).isEqualTo(bound).isNotSameAs(bound);
- }
-
- @Test
- public void testCopyXYZM() {
- GeospatialBound bound = GeospatialBound.createXYZM(1.0, 2.0, 3.0, 4.0);
- GeospatialBound copy = bound.copy();
- assertThat(copy).isEqualTo(bound).isNotSameAs(bound);
+ assertThatThrownBy(() -> bound.set(0, 9.0))
+ .isInstanceOf(UnsupportedOperationException.class)
+ .hasMessage("GeospatialBound is read only");
}
@Test
diff --git a/core/src/main/java/org/apache/iceberg/FieldStatsStruct.java
b/core/src/main/java/org/apache/iceberg/FieldStatsStruct.java
index cbfc78a5ed..67d97ba512 100644
--- a/core/src/main/java/org/apache/iceberg/FieldStatsStruct.java
+++ b/core/src/main/java/org/apache/iceberg/FieldStatsStruct.java
@@ -22,11 +22,11 @@ import java.io.Serializable;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
-import org.apache.iceberg.geospatial.GeospatialBound;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.types.Type;
import org.apache.iceberg.types.Types;
import org.apache.iceberg.util.ByteBuffers;
+import org.apache.iceberg.util.StructLikeUtil;
class FieldStatsStruct<T> implements FieldStats<T>, StructLike, Serializable {
private final Types.StructType struct;
@@ -224,9 +224,8 @@ class FieldStatsStruct<T> implements FieldStats<T>,
StructLike, Serializable {
private static Object copyBound(Object bound) {
if (bound instanceof byte[] bytes) {
return copyOf(bytes);
- } else if (bound instanceof GeospatialBound geo) {
- // readers reuse one bound instance
- return geo.copy();
+ } else if (bound instanceof StructLike struct) {
+ return StructLikeUtil.copy(struct);
}
return bound;
diff --git a/core/src/main/java/org/apache/iceberg/V4ManifestReader.java
b/core/src/main/java/org/apache/iceberg/V4ManifestReader.java
index abea2e1878..c2e549c7f5 100644
--- a/core/src/main/java/org/apache/iceberg/V4ManifestReader.java
+++ b/core/src/main/java/org/apache/iceberg/V4ManifestReader.java
@@ -31,7 +31,6 @@ import org.apache.iceberg.expressions.Expression;
import org.apache.iceberg.expressions.Expressions;
import org.apache.iceberg.expressions.InclusiveStatsEvaluator;
import org.apache.iceberg.expressions.Projections;
-import org.apache.iceberg.geospatial.GeospatialBound;
import org.apache.iceberg.io.CloseableGroup;
import org.apache.iceberg.io.CloseableIterable;
import org.apache.iceberg.io.CloseableIterator;
@@ -301,7 +300,6 @@ class V4ManifestReader extends CloseableGroup implements
CloseableIterable<Track
readBuilder.setCustomType(TrackedFile.CONTENT_STATS_ID,
ContentStatsStruct.class);
for (Types.NestedField fieldStats :
statsField.type().asStructType().fields()) {
readBuilder.setCustomType(fieldStats.fieldId(),
FieldStatsStruct.class);
- registerCustomBoundTypes(readBuilder, fieldStats);
}
}
@@ -310,22 +308,6 @@ class V4ManifestReader extends CloseableGroup implements
CloseableIterable<Track
return reader;
}
- private static void registerCustomBoundTypes(
- InternalData.ReadBuilder readBuilder, Types.NestedField fieldStats) {
- Types.StructType struct = fieldStats.type().asStructType();
- registerGeoBoundType(readBuilder,
struct.field(StatsUtil.LOWER_BOUND_NAME));
- registerGeoBoundType(readBuilder,
struct.field(StatsUtil.UPPER_BOUND_NAME));
- }
-
- private static void registerGeoBoundType(
- InternalData.ReadBuilder readBuilder, Types.NestedField boundField) {
- // Geometry and geography are the only bound types represented as structs,
so a struct bound
- // is read as GeospatialBound.
- if (boundField != null && boundField.type().isStructType()) {
- readBuilder.setCustomType(boundField.fieldId(), GeospatialBound.class);
- }
- }
-
// resolves stored locations against the table location
private TrackedFile copyResolved(TrackedFile trackedFile) {
TrackedFileStruct copy =
@@ -582,8 +564,7 @@ class V4ManifestReader extends CloseableGroup implements
CloseableIterable<Track
return RestoreColumns.restore(
tableManifestSchema,
requestedProjection,
- idsToRestore(
- projectsPartition(includePartition, requestedProjection),
requestedProjection));
+ idsToRestore(projectsPartition(includePartition,
requestedProjection)));
}
if (requestedColumns != null) {
@@ -595,7 +576,7 @@ class V4ManifestReader extends CloseableGroup implements
CloseableIterable<Track
return RestoreColumns.restore(
tableManifestSchema,
projection,
- idsToRestore(projectsPartition(includePartition, projection),
projection));
+ idsToRestore(projectsPartition(includePartition, projection)));
}
return tableManifestSchema;
@@ -606,7 +587,7 @@ class V4ManifestReader extends CloseableGroup implements
CloseableIterable<Track
}
/** Return a set of manifest field IDs that should be projected. */
- private Set<Integer> idsToRestore(boolean includePartition, Schema
projection) {
+ private Set<Integer> idsToRestore(boolean includePartition) {
Set<Integer> ids = Sets.newHashSet(REQUIRED_COLUMN_IDS);
// project the full stats struct that corresponds to each field for
which stats are needed
@@ -622,36 +603,9 @@ class V4ManifestReader extends CloseableGroup implements
CloseableIterable<Track
ids.add(TrackedFile.PARTITION_ID);
}
- // A partial geo bound must be read whole: GeospatialBound positions are
fixed and NaN means
- // absent in the file.
- addProjectedGeoBounds(projection, ids);
-
return ids;
}
- private static void addProjectedGeoBounds(Schema projection, Set<Integer>
ids) {
- Types.NestedField contentStatsField =
projection.findField(TrackedFile.CONTENT_STATS_ID);
- if (contentStatsField == null ||
!contentStatsField.type().isStructType()) {
- return;
- }
-
- for (Types.NestedField fieldStats :
contentStatsField.type().asStructType().fields()) {
- if (!fieldStats.type().isStructType()) {
- continue;
- }
-
- Types.StructType struct = fieldStats.type().asStructType();
- addGeoBoundId(struct.field(StatsUtil.LOWER_BOUND_NAME), ids);
- addGeoBoundId(struct.field(StatsUtil.UPPER_BOUND_NAME), ids);
- }
- }
-
- private static void addGeoBoundId(Types.NestedField bound, Set<Integer>
ids) {
- if (bound != null && bound.type().isStructType()) {
- ids.add(bound.fieldId());
- }
- }
-
/** Return a set of table field IDs for which stats are needed. */
private Set<Integer> statsFieldIds() {
Set<Integer> filterFieldIds =
diff --git a/core/src/test/java/org/apache/iceberg/TestFieldStatsStruct.java
b/core/src/test/java/org/apache/iceberg/TestFieldStatsStruct.java
index c2e74307ac..9cd893c12c 100644
--- a/core/src/test/java/org/apache/iceberg/TestFieldStatsStruct.java
+++ b/core/src/test/java/org/apache/iceberg/TestFieldStatsStruct.java
@@ -30,7 +30,6 @@ import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import org.apache.iceberg.TestHelpers.RoundTripSerializer;
-import org.apache.iceberg.geospatial.GeospatialBound;
import org.apache.iceberg.inmemory.InMemoryOutputFile;
import org.apache.iceberg.io.CloseableIterable;
import org.apache.iceberg.io.FileAppender;
@@ -280,19 +279,7 @@ public class TestFieldStatsStruct {
private static Stream<Arguments> geoCases() {
return ImmutableList.of(Types.GeometryType.crs84(),
Types.GeographyType.crs84()).stream()
- .flatMap(
- type ->
- SERIALIZERS.stream()
- .map(serializer -> Arguments.of(type,
geoSerializer(serializer, type))));
- }
-
- private static Named<RoundTripSerializer<FieldStatsStruct<?>>> geoSerializer(
- Named<RoundTripSerializer<FieldStatsStruct<?>>> serializer, Type type) {
- if ("InternalData".equals(serializer.getName())) {
- return Named.of("InternalData", stats -> roundTripInternalData(stats,
type));
- }
-
- return serializer;
+ .flatMap(type -> SERIALIZERS.stream().map(serializer ->
Arguments.of(type, serializer)));
}
@ParameterizedTest
@@ -303,8 +290,18 @@ public class TestFieldStatsStruct {
StatsUtil.fieldStatsStruct(geoType, BASE_ID, MetricsModes.Full.get());
// geometry and geography use bounding-box structs (x, y, z, m) for their
bounds
- GeospatialBound lowerBound = GeospatialBound.createXYZM(1.0d, 2.0d, 3.0d,
4.0d);
- GeospatialBound upperBound = GeospatialBound.createXYZM(5.0d, 6.0d, 7.0d,
8.0d);
+ PartitionData lowerBound =
+ new
PartitionData(statsStruct.field("lower_bound").type().asStructType());
+ lowerBound.set(0, 1.0d);
+ lowerBound.set(1, 2.0d);
+ lowerBound.set(2, 3.0d);
+ lowerBound.set(3, 4.0d);
+ PartitionData upperBound =
+ new
PartitionData(statsStruct.field("upper_bound").type().asStructType());
+ upperBound.set(0, 5.0d);
+ upperBound.set(1, 6.0d);
+ upperBound.set(2, 7.0d);
+ upperBound.set(3, 8.0d);
FieldStatsStruct<Object> stats =
new FieldStatsStruct<>(statsStruct, lowerBound, upperBound, 28L, 2L,
0L, 23L);
@@ -369,11 +366,6 @@ public class TestFieldStatsStruct {
private static <T> FieldStatsStruct<T> roundTripInternalData(FieldStats<T>
stats)
throws IOException {
- return roundTripInternalData(stats, null);
- }
-
- private static <T> FieldStatsStruct<T> roundTripInternalData(FieldStats<T>
stats, Type columnType)
- throws IOException {
Schema schema = stats.type().asSchema();
InMemoryOutputFile file = new InMemoryOutputFile("internal.avro");
@@ -382,29 +374,15 @@ public class TestFieldStatsStruct {
writer.add(stats);
}
- InternalData.ReadBuilder readBuilder =
+ try (CloseableIterable<FieldStatsStruct<T>> reader =
InternalData.read(FileFormat.AVRO, file.toInputFile())
.project(schema)
- .setRootType(FieldStatsStruct.class);
- if (columnType != null
- && (columnType.typeId() == Type.TypeID.GEOMETRY
- || columnType.typeId() == Type.TypeID.GEOGRAPHY)) {
- setGeospatialBoundCustomType(readBuilder,
stats.type().field(StatsUtil.LOWER_BOUND_NAME));
- setGeospatialBoundCustomType(readBuilder,
stats.type().field(StatsUtil.UPPER_BOUND_NAME));
- }
-
- try (CloseableIterable<FieldStatsStruct<T>> reader = readBuilder.build()) {
+ .setRootType(FieldStatsStruct.class)
+ .build()) {
return Iterables.getOnlyElement(reader);
}
}
- private static void setGeospatialBoundCustomType(
- InternalData.ReadBuilder readBuilder, Types.NestedField boundField) {
- if (boundField != null) {
- readBuilder.setCustomType(boundField.fieldId(), GeospatialBound.class);
- }
- }
-
private static int pos(Types.StructType type, String fieldName) {
List<Types.NestedField> fields = type.fields();
for (int pos = 0; pos < fields.size(); pos += 1) {
diff --git a/core/src/test/java/org/apache/iceberg/TestV4ManifestReader.java
b/core/src/test/java/org/apache/iceberg/TestV4ManifestReader.java
index 54211f13a8..e7e44b3d10 100644
--- a/core/src/test/java/org/apache/iceberg/TestV4ManifestReader.java
+++ b/core/src/test/java/org/apache/iceberg/TestV4ManifestReader.java
@@ -52,7 +52,6 @@ import java.util.function.Consumer;
import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.expressions.Expression;
import org.apache.iceberg.expressions.Expressions;
-import org.apache.iceberg.geospatial.GeospatialBound;
import org.apache.iceberg.inmemory.InMemoryFileIO;
import org.apache.iceberg.io.CloseableIterator;
import org.apache.iceberg.io.OutputFile;
@@ -1978,85 +1977,6 @@ class TestV4ManifestReader {
"s3://bucket/db/table/data/rel.parquet",
"s3://other/abs-dv.puffin"));
}
- @ParameterizedTest
- @FieldSource("MANIFEST_FORMATS")
- public void readGeospatialBounds(FileFormat format) throws IOException {
- Schema schema =
- new Schema(
- optional(1, "geom", Types.GeometryType.crs84()),
- optional(2, "geog", Types.GeographyType.crs84()));
- MetricsConfig metricsConfig = MetricsTestUtil.from(ImmutableMap.of(),
schema);
- Types.StructType statsType = StatsUtil.statsWriteSchema(schema,
metricsConfig);
-
- GeospatialBound geomLower = GeospatialBound.createXYZM(1.0, 2.0, 3.0, 4.0);
- GeospatialBound geomUpper = GeospatialBound.createXYZM(5.0, 6.0, 7.0, 8.0);
- GeospatialBound geogLower = GeospatialBound.createXY(-10.0, -20.0);
- GeospatialBound geogUpper = GeospatialBound.createXY(30.0, 40.0);
- GeospatialBound nextGeomLower = GeospatialBound.createXY(11.0, 12.0);
- GeospatialBound nextGeomUpper = GeospatialBound.createXYZ(15.0, 16.0,
17.0);
- GeospatialBound nextGeogLower = GeospatialBound.createXYM(-1.0, -2.0, 9.0);
- GeospatialBound nextGeogUpper = GeospatialBound.createXYZM(3.0, 4.0, 5.0,
6.0);
-
- TrackedFile first =
- dataFileWithStats(
- "s3://bucket/table/geo-a.parquet",
- contentStats(statsType, geomLower, geomUpper, geogLower,
geogUpper));
- TrackedFile second =
- dataFileWithStats(
- "s3://bucket/table/geo-b.parquet",
- contentStats(statsType, nextGeomLower, nextGeomUpper,
nextGeogLower, nextGeogUpper));
-
- ManifestFile manifest =
- writeManifest(format, UNPARTITIONED_TYPE, statsType,
ImmutableList.of(first, second));
-
- V4ManifestReader.Builder builder =
- V4ManifestReader.builder(manifest, IO, schema, UNPARTITIONED_SPECS)
- .metricsConfig(metricsConfig);
-
- List<TrackedFile> files = read(builder);
- assertThat(files).hasSize(2);
- assertGeospatialBounds(files.get(0), geomLower, geomUpper, geogLower,
geogUpper);
- assertGeospatialBounds(
- files.get(1), nextGeomLower, nextGeomUpper, nextGeogLower,
nextGeogUpper);
- assertThat(files.get(0).contentStats().statsFor(1).lowerBound())
- .isNotSameAs(files.get(1).contentStats().statsFor(1).lowerBound());
- }
-
- @ParameterizedTest
- @FieldSource("MANIFEST_FORMATS")
- public void readPartialGeospatialBound(FileFormat format) throws IOException
{
- Schema schema =
- new Schema(
- optional(1, "geom", Types.GeometryType.crs84()),
- optional(2, "geog", Types.GeographyType.crs84()));
- MetricsConfig metricsConfig = MetricsTestUtil.from(ImmutableMap.of(),
schema);
- Types.StructType statsType = StatsUtil.statsWriteSchema(schema,
metricsConfig);
-
- GeospatialBound geomLower = GeospatialBound.createXYZM(1.0, 2.0, 3.0, 4.0);
- GeospatialBound geomUpper = GeospatialBound.createXYZM(5.0, 6.0, 7.0, 8.0);
- GeospatialBound geogLower = GeospatialBound.createXY(-10.0, -20.0);
- GeospatialBound geogUpper = GeospatialBound.createXY(30.0, 40.0);
- TrackedFile file =
- dataFileWithStats(
- "s3://bucket/table/geo-partial.parquet",
- contentStats(statsType, geomLower, geomUpper, geogLower,
geogUpper));
-
- ManifestFile manifest =
- writeManifest(format, UNPARTITIONED_TYPE, statsType,
ImmutableList.of(file));
-
- V4ManifestReader.Builder builder =
- V4ManifestReader.builder(manifest, IO, schema, UNPARTITIONED_SPECS)
- .metricsConfig(metricsConfig)
- // selecting m still reads the full geometry and geography bound
structs
- .select(
- "content_stats.geom.lower_bound.m",
- "content_stats.geom.upper_bound.m",
- "content_stats.geog.lower_bound.m",
- "content_stats.geog.upper_bound.m");
-
- assertGeospatialBounds(readOne(builder), geomLower, geomUpper, geogLower,
geogUpper);
- }
-
@ParameterizedTest
@FieldSource("MANIFEST_FORMATS")
public void readManifestLocations(FileFormat format) throws IOException {
@@ -2105,44 +2025,6 @@ class TestV4ManifestReader {
assertThat(locations).containsExactly(dataManifest.location(),
deleteManifest.location());
}
- private static ContentStats contentStats(
- Types.StructType statsType,
- GeospatialBound geomLower,
- GeospatialBound geomUpper,
- GeospatialBound geogLower,
- GeospatialBound geogUpper) {
- ContentStatsStruct stats = new ContentStatsStruct(statsType);
- stats.setStats(1, geoFieldStats(statsType, "geom", geomLower, geomUpper));
- stats.setStats(2, geoFieldStats(statsType, "geog", geogLower, geogUpper));
- return stats;
- }
-
- private static FieldStatsStruct<GeospatialBound> geoFieldStats(
- Types.StructType statsType, String name, GeospatialBound lower,
GeospatialBound upper) {
- return new FieldStatsStruct<>(
- statsType.fieldType(name).asStructType(), lower, upper, RECORD_COUNT,
0, 0, 0L);
- }
-
- private static void assertGeospatialBounds(
- TrackedFile file,
- GeospatialBound geomLower,
- GeospatialBound geomUpper,
- GeospatialBound geogLower,
- GeospatialBound geogUpper) {
- assertBound(file, 1, geomLower, geomUpper);
- assertBound(file, 2, geogLower, geogUpper);
- }
-
- private static void assertBound(
- TrackedFile file, int fieldId, GeospatialBound lower, GeospatialBound
upper) {
- assertThat(file.contentStats().statsFor(fieldId).lowerBound())
- .isInstanceOf(GeospatialBound.class)
- .isEqualTo(lower);
- assertThat(file.contentStats().statsFor(fieldId).upperBound())
- .isInstanceOf(GeospatialBound.class)
- .isEqualTo(upper);
- }
-
private static TrackedFile unpartitionedFileWithoutStats(String location) {
Tracking tracking =
new TrackingStruct(
@@ -2182,16 +2064,7 @@ class TestV4ManifestReader {
private ManifestFile writeManifest(
FileFormat format, Types.StructType partitionType, List<TrackedFile>
files)
throws IOException {
- return writeManifest(format, partitionType, STATS_TYPE, files);
- }
-
- private ManifestFile writeManifest(
- FileFormat format,
- Types.StructType partitionType,
- Types.StructType statsType,
- List<TrackedFile> files)
- throws IOException {
- OutputFile out = writeTrackedFiles(IO, format, partitionType, statsType,
files);
+ OutputFile out = writeTrackedFiles(IO, format, partitionType, STATS_TYPE,
files);
return v4Manifest(out.location());
}