Skip to content

[GH-3036] Flink Box3D foundation: Box3DTypeSerializer + ST_Box3D / ST_3DMakeBox#3037

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:feature/flink-box3d-foundation
Jun 10, 2026
Merged

[GH-3036] Flink Box3D foundation: Box3DTypeSerializer + ST_Box3D / ST_3DMakeBox#3037
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:feature/flink-box3d-foundation

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

  • Yes

Is this PR related to a ticket?

  • Yes — closes #3036; follow-up to the Box3D EPIC (#2973).

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 — Flink TypeSerializer<Box3D> mirroring Box2DTypeSerializer. Presence byte + six doubles (xmin, ymin, zmin, xmax, ymax, zmax); 49-byte payload for a non-null value. Includes the Box3DSerializerSnapshot for state compatibility.
  • Functions.ST_Box3D(geom) → Box3D — wraps org.apache.sedona.common.Functions.box3D.
  • Constructors.ST_3DMakeBox(pointZ, pointZ) → Box3D — wraps org.apache.sedona.common.Constructors.make3DBox.
  • Registered all three in Catalog.

How was this patch tested?

  • ConstructorTest.testMake3DBox — build a Box3D from two POINT Z corners, assert all six bounds.
  • FunctionTest.testBox3DST_Box3D over an XYZ linestring, the XY-only fold to Z=0, and NULL / empty propagation.
  • Full ConstructorTest + FunctionTest run: 238 tests pass locally.

Did this PR include necessary documentation updates?

  • No — Box3D documentation is tracked separately under the Box3D EPIC.

Out of scope (later Flink slices)

  • Box3D accessors (ST_XMinST_ZMax), ST_AsText(box3d), ST_Expand(box3d).
  • ST_3DExtent aggregate.
  • Box3D overloads on ST_Intersects / ST_Contains; ST_3DDWithin.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RAW Box3D values.
  • Adds Flink scalar functions ST_Box3D(geom) and ST_3DMakeBox(p1, p2) and registers them in the Flink Catalog.
  • 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.
@jiayuasu jiayuasu force-pushed the feature/flink-box3d-foundation branch from 7e045ee to 7ea61fc Compare June 10, 2026 06:55
@jiayuasu jiayuasu merged commit 52e9f38 into apache:master Jun 10, 2026
19 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flink Box3D foundation: Box3DTypeSerializer + ST_Box3D / ST_3DMakeBox

2 participants