[GH-3012] Box3D predicates: ST_3DBoxIntersects and ST_3DBoxContains#3014
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two Box3D-on-Box3D spatial predicates — ST_3DBoxIntersects and ST_3DBoxContains — completing slice #4 of the Box3D Phase 1 epic. Both predicates use closed-interval semantics (matching PostGIS &&& and ~~ on box3d), reject inverted bounds on any axis with IllegalArgumentException, and propagate NULL. Implementation mirrors the existing Box2D predicate shape.
Changes:
- Adds
Predicates.box3dIntersectsandPredicates.box3dContainsin Java common, with sharedrequireOrderedBox3Dhelper. - Adds Catalyst
ST_3DBoxIntersects/ST_3DBoxContainscase classes viaInferredExpressionand registers them underpredicateExprsinCatalog. - Adds Java unit tests in
PredicatesTestand a newBox3DPredicateSuiteSQL test.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| common/src/main/java/org/apache/sedona/common/Predicates.java | Adds box3dIntersects / box3dContains and a Box3D ordering helper. |
| common/src/test/java/org/apache/sedona/common/PredicatesTest.java | Unit tests for overlap, touch, disjoint, containment, equal-box, and inverted-bound rejection. |
| spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Predicates.scala | Catalyst case-class wrappers for the two predicates. |
| spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala | Registers ST_3DBoxContains / ST_3DBoxIntersects in predicateExprs. |
| spark/common/src/test/scala/org/apache/sedona/sql/Box3DPredicateSuite.scala | End-to-end SQL tests for the new predicates, including NULL propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ains Fourth slice of the Box3D Phase 1 epic. Adds the two PostGIS-compatible 3D bbox predicates, mirroring the Box2D predicate shape. - `Predicates.box3dIntersects(Box3D, Box3D)`: closed-interval intersection on all three axes. Mirrors PostGIS `&&&` on box3d. - `Predicates.box3dContains(Box3D, Box3D)`: closed-interval containment on all three axes. Equal boxes contain each other. - Both predicates require ordered bounds (xmin <= xmax, ymin <= ymax, zmin <= zmax) and throw IllegalArgumentException on inverted input. Unlike Box2D — where inverted X is reserved for future antimeridian wraparound — Z has no wraparound convention, so all three axes have the same strict ordering requirement. - `ST_3DBoxIntersects` and `ST_3DBoxContains` Catalyst case classes wired through `InferredExpression` and registered in the Catalog. - Java unit tests in `PredicatesTest` covering all the cases parallel to the Box2D tests (overlap, face/edge/corner touch, disjoint, containment with equal/crossing/strict-subset, inverted-bounds reject). - `Box3DPredicateSuite` covers the SQL surface: same predicate scenarios end-to-end, inverted-bounds throw at SQL level, and NULL propagation. Remaining: ST_3DExtent aggregate (final slice).
37b9d82 to
ab970ce
Compare
3 tasks
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?
Fourth slice of the Box3D Phase 1 epic. Builds on the type + constructors + accessors merged in #2978, #2984, #3005. Adds the two PostGIS-compatible 3D bbox predicates, mirroring the existing Box2D predicate shape.
Predicates.box3dIntersects(Box3D, Box3D)— closed-interval intersection on all three axes. Mirrors PostGIS&&&onbox3d.Predicates.box3dContains(Box3D, Box3D)— closed-interval containment on all three axes. Equal boxes contain each other.xmin <= xmax,ymin <= ymax,zmin <= zmax) and throwIllegalArgumentExceptionon inverted input. Unlike Box2D — where inverted X is reserved for a future antimeridian-wraparound convention — Z has no wraparound semantics, so all three axes share the same strict ordering requirement.ST_3DBoxIntersects/ST_3DBoxContainsCatalyst case classes wired throughInferredExpressionand registered in the Catalog.How was this patch tested?
PredicatesTest(parallel to the Box2D coverage: overlap, face/edge/corner touch, disjoint, containment with equal / crossing / strict-subset, inverted-bounds reject).Tests run: 18, Failures: 0.Box3DPredicateSuitecovering the SQL surface end-to-end. 4 tests, all green locally.Did this PR include necessary documentation updates?