[GH-3042] Flink Box3D predicates: ST_Intersects / ST_Contains + ST_3DDWithin#3043
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes the Flink “Box3D predicates” slice by adding Box3D overloads for existing ST_Intersects/ST_Contains and introducing a new ST_3DDWithin predicate, aligning Flink’s Box3D predicate surface with Sedona’s common-layer Box3D predicate implementations.
Changes:
- Added Box3D overloads to Flink
ST_IntersectsandST_Containsdelegating toorg.apache.sedona.common.Predicates.box3dIntersects/box3dContains. - Added new Flink scalar function
ST_3DDWithinwith Geometry and Box3D overloads delegating toorg.apache.sedona.common.Predicates.dWithin3D. - Registered
ST_3DDWithinin the FlinkCatalogand added corresponding Flink SQL tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| flink/src/test/java/org/apache/sedona/flink/PredicateTest.java | Adds Flink SQL tests covering Box3D intersects/contains semantics and ST_3DDWithin threshold behavior. |
| flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java | Implements Box3D overloads for ST_Intersects/ST_Contains and adds the new ST_3DDWithin scalar function. |
| flink/src/main/java/org/apache/sedona/flink/Catalog.java | Registers ST_3DDWithin among Flink predicate UDFs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| bridgedTo = Geometry.class) | ||
| Object o2, | ||
| @DataTypeHint("Double") Double distance) { | ||
| if (o1 == null || o2 == null) return null; |
There was a problem hiding this comment.
Fixed in latest push: the geometry overload now guards distance == null (alongside the existing o1/o2 null guards) and returns NULL. Added a NULL-distance assertion to PredicateTest.test3DDWithin. The pre-existing ST_DWithin has the same gap (NULL distance and NULL geometry both NPE); tracked separately in #3046 to keep this PR scoped to Box3D.
| bridgedTo = Box3D.class) | ||
| Box3D b, | ||
| @DataTypeHint("Double") Double distance) { | ||
| if (a == null || b == null) return null; |
There was a problem hiding this comment.
Fixed in latest push: the Box3D overload now guards distance == null and returns NULL, with a NULL-distance assertion added to the test. See #3046 for the parallel ST_DWithin cleanup.
|
One thing to fix before merge: Please add mvn -pl flink -Dtest=PredicateTest test |
… ST_3DDWithin Final Flink Box3D slice, bringing the Flink predicate surface to parity with Spark's Box3D predicates. - ST_Intersects / ST_Contains: Box3D eval overloads wrapping Predicates.box3dIntersects / box3dContains, mirroring the Box2D overloads already on these classes. - New ST_3DDWithin scalar function: (Geometry, Geometry, Double) → dWithin3D (missing Z folds to 0) and (Box3D, Box3D, Double) → dWithin3D. NULL-guarded. - Registered ST_3DDWithin in Catalog. Tests: - PredicateTest.testIntersectsOnBox3D / testContainsOnBox3D: the XY-overlapping-but-Z-disjoint rows confirm the Z axis is enforced. - PredicateTest.test3DDWithin: Geometry POINT Z within / just-outside, plus Box3D-on-Box3D faces-apart-in-Z within / just-outside. This completes Flink Box3D parity with the Spark surface.
0b880da to
8ea92c8
Compare
Did you read the Contributor Guide?
Is this PR related to a ticket?
What changes were proposed in this PR?
Final Flink Box3D slice. Brings the Flink predicate surface to parity with Spark's Box3D predicates (consolidated into
ST_Intersects/ST_Containsplus the standaloneST_3DDWithin).ST_Intersects/ST_Contains: Box3Devaloverloads wrappingPredicates.box3dIntersects/box3dContains. Mirrors the Box2D overloads already on these classes.ST_3DDWithin: new scalar function with two overloads —(Geometry, Geometry, Double)→dWithin3D(missing Z folds to 0), and(Box3D, Box3D, Double)→dWithin3D. NULL-guarded like the Box overloads. Registered inCatalog.How was this patch tested?
PredicateTest.testIntersectsOnBox3D/testContainsOnBox3D— XY-overlapping-but-Z-disjoint rows confirm the Z axis is enforced (not just an XY-footprint check).PredicateTest.test3DDWithin— Geometry POINT Z within / just-outside the threshold, plus Box3D-on-Box3D faces-apart-in-Z within / just-outside.PredicateTest: 21 pass.Did this PR include necessary documentation updates?
Completion
This completes Flink Box3D parity with the shipped Spark surface: type + serializer, constructors, accessors,
ST_AsText,ST_3DExtent, and predicates.