Skip to content

[GH-2888] Flink bindings for Box2D Phase 1 surface#2906

Merged
jiayuasu merged 2 commits intoapache:masterfrom
jiayuasu:feature/box2d-flink-bindings
May 7, 2026
Merged

[GH-2888] Flink bindings for Box2D Phase 1 surface#2906
jiayuasu merged 2 commits intoapache:masterfrom
jiayuasu:feature/box2d-flink-bindings

Conversation

@jiayuasu
Copy link
Copy Markdown
Member

@jiayuasu jiayuasu commented May 6, 2026

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

Mirrors the Phase 1 Box2D SQL surface in the Flink module.

Type system

  • flink/src/main/java/org/apache/sedona/flink/Box2DTypeSerializer.java — Flink TypeSerializer<Box2D>. Same shape as GeometryTypeSerializer (used as a RAW data type via @DataTypeHint(rawSerializer = ..., bridgedTo = ...)). Encodes a presence byte plus four doubles.

Scalars and aggregate

Function Module Notes
ST_Box2D(geom) Functions scalar
ST_MakeBox2D(p1, p2) Constructors scalar
ST_GeomFromBox2D(box) Constructors scalar; dispatches POLYGON/POINT/LINESTRING
ST_Extent(geom) Aggregators aggregate, returns Box2D, NULL over zero rows
ST_XMin/XMax/YMin/YMax(box) Functions new eval(Box2D) overloads on the existing classes
ST_AsText(box) Functions new eval(Box2D) overload returning BOX(...)

Plus Catalog registration for the four new top-level functions (ST_Box2D, ST_MakeBox2D, ST_GeomFromBox2D, ST_Extent).

How was this patch tested?

  • flink/src/test/.../FunctionTest.javatestBox2D (happy path + NULL propagation), testBox2DAsTextAndAccessors (BOX format and the four 2D accessors against a Box2D value).
  • flink/src/test/.../ConstructorTest.javatestMakeBox2D (happy path), testGeomFromBox2D (POLYGON + degenerate POINT cases through ST_AsText).
  • flink/src/test/.../AggregatorTest.javatestExtent (happy path), testExtent_EmptyAndNullGeometries (NULL/empty input → NULL).

Did this PR include necessary documentation updates?

Mirrors the Phase 1 SQL surface in Flink:

- Box2DTypeSerializer (RAW Flink TypeSerializer for Box2D)
- ST_Box2D scalar in Functions
- ST_MakeBox2D, ST_GeomFromBox2D scalars in Constructors
- ST_Extent aggregate in Aggregators
- Box2D eval overloads on ST_XMin, ST_XMax, ST_YMin, ST_YMax, ST_AsText
- Catalog registration for the four new top-level functions

Tests in FunctionTest, ConstructorTest, AggregatorTest cover the
happy path, NULL/empty propagation, and the dimensionality dispatch
in ST_GeomFromBox2D.

Closes apache#2888.
@jiayuasu jiayuasu requested a review from Copilot May 6, 2026 17:06
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone May 6, 2026
(0, 0) is Null Island — equator × prime meridian — a real point. A
zero-zero Box2D used as an aggregation seed or initial value would
silently include the origin in every result.

Box2D has no in-band empty marker; absence is represented by SQL
NULL. Returning null from createInstance() is the honest default and
matches our type contract.

The ST_Extent aggregator was never affected (it uses
Accumulators.Envelope with +inf/-inf, not Box2D), but the precedent
in createInstance() should not be a footgun.
@jiayuasu jiayuasu merged commit d9717a4 into apache:master May 7, 2026
19 checks passed
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 bindings for Box2D scalar functions and ST_Extent

1 participant