[GH-3036] Flink Box3D foundation: Box3DTypeSerializer + ST_Box3D / ST_3DMakeBox#3037
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds foundational Box3D support to the Flink module (paralleling existing Box2D support) so Box3D values can be constructed, returned from UDFs, and round-tripped through Flink’s type system.
Changes:
- Introduces
Box3DTypeSerializer(+ serializer snapshot) for Flink RAWBox3Dvalues. - Adds Flink scalar functions
ST_Box3D(geom)andST_3DMakeBox(p1, p2)and registers them in the FlinkCatalog. - Adds Flink SQL tests covering Box3D bounds, XY→Z=0 folding, and NULL/empty propagation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| flink/src/main/java/org/apache/sedona/flink/Box3DTypeSerializer.java | Adds Flink TypeSerializer<Box3D> + snapshot mirroring the existing Box2D serializer pattern. |
| flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java | Adds ST_Box3D scalar function with RAW type hint using Box3DTypeSerializer. |
| flink/src/main/java/org/apache/sedona/flink/expressions/Constructors.java | Adds ST_3DMakeBox scalar function with RAW type hint using Box3DTypeSerializer. |
| flink/src/main/java/org/apache/sedona/flink/Catalog.java | Registers ST_3DMakeBox and ST_Box3D in the UDF catalog. |
| flink/src/test/java/org/apache/sedona/flink/FunctionTest.java | Adds testBox3D to validate bounds, XY folding, and NULL/empty behavior. |
| flink/src/test/java/org/apache/sedona/flink/ConstructorTest.java | Adds testMake3DBox to validate constructor behavior and bound ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…D / ST_3DMakeBox First slice of porting Box3D to the Flink module, mirroring the Box2D surface. Lands the serializer plus the two constructors so a Box3D can be produced and round-tripped through Flink's type system. - Box3DTypeSerializer: Flink TypeSerializer<Box3D> mirroring Box2DTypeSerializer. Presence byte + six doubles (xmin, ymin, zmin, xmax, ymax, zmax); 49-byte non-null payload. Includes Box3DSerializerSnapshot for state compatibility. - Functions.ST_Box3D(geom) → Box3D, wrapping common Functions.box3D. - Constructors.ST_3DMakeBox(pointZ, pointZ) → Box3D, wrapping common Constructors.make3DBox. - Registered all three in Catalog. Tests: - ConstructorTest.testMake3DBox: build a Box3D from two POINT Z corners, assert all six bounds. - FunctionTest.testBox3D: ST_Box3D over an XYZ linestring, XY-only fold to Z=0, and NULL / empty propagation. Out of scope (later Flink slices): Box3D accessors / ST_AsText / ST_Expand, ST_3DExtent aggregate, Box3D ST_Intersects / ST_Contains overloads, ST_3DDWithin.
7e045ee to
7ea61fc
Compare
This was referenced Jun 10, 2026
jiayuasu
added a commit
to jiayuasu/sedona
that referenced
this pull request
Jun 11, 2026
Second Flink Box3D slice, building on the foundation in apache#3037. Adds the Box3D accessor overloads, the BOX3D text form, and the 3D extent aggregate — mirroring the Box2D Flink surface. - Functions: Box3D eval overloads on ST_XMin / ST_YMin / ST_ZMin / ST_XMax / ST_YMax / ST_ZMax (ST_ZMin / ST_ZMax previously had only the Geometry overload), and ST_AsText(box3d) → box3dAsText. - Aggregators.ST_3DExtent: AggregateFunction<Box3D, Envelope3D> mirroring ST_Extent. Per-row folding via Functions.box3D (missing Z → 0, empty → skipped); returns null on an all-empty/null input. - Accumulators.Envelope3D: six-double mutable accumulator. - Registered ST_3DExtent in Catalog (the accessors / ST_AsText gain overloads on already-registered classes, so no new registration). Note: ST_Expand has no Box3D overload — the common layer has no expand(Box3D, ...) and the Spark Box3D surface doesn't expose it either, so it stays out of scope. Tests: - FunctionTest.testBox3DAsTextAndAccessors: BOX3D text + all six accessors over a Box3D. - AggregatorTest.test3DExtent: mixed XYZ / XY-fold-to-0 rows; and test3DExtent_EmptyAndNullGeometries: all-empty/null → NULL. Out of scope (final Flink slice): Box3D ST_Intersects / ST_Contains overloads, ST_3DDWithin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
What changes were proposed in this PR?
The Spark + Python Box3D surface is shipped, but the Flink module had no Box3D support at all — only Box2D. This is the foundation slice of porting Box3D to Flink, mirroring the Box2D structure. It lands the serializer plus the two constructors so a Box3D value can be produced and round-tripped through Flink's type system.
Box3DTypeSerializer— FlinkTypeSerializer<Box3D>mirroringBox2DTypeSerializer. Presence byte + six doubles (xmin, ymin, zmin, xmax, ymax, zmax); 49-byte payload for a non-null value. Includes theBox3DSerializerSnapshotfor state compatibility.Functions.ST_Box3D(geom) → Box3D— wrapsorg.apache.sedona.common.Functions.box3D.Constructors.ST_3DMakeBox(pointZ, pointZ) → Box3D— wrapsorg.apache.sedona.common.Constructors.make3DBox.Catalog.How was this patch tested?
ConstructorTest.testMake3DBox— build a Box3D from two POINT Z corners, assert all six bounds.FunctionTest.testBox3D—ST_Box3Dover an XYZ linestring, the XY-only fold to Z=0, and NULL / empty propagation.ConstructorTest+FunctionTestrun: 238 tests pass locally.Did this PR include necessary documentation updates?
Out of scope (later Flink slices)
ST_XMin…ST_ZMax),ST_AsText(box3d),ST_Expand(box3d).ST_3DExtentaggregate.ST_Intersects/ST_Contains;ST_3DDWithin.