Skip to content

[GH-3012] Box3D predicates: ST_3DBoxIntersects and ST_3DBoxContains#3014

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:feature/box3d-predicates
May 30, 2026
Merged

[GH-3012] Box3D predicates: ST_3DBoxIntersects and ST_3DBoxContains#3014
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:feature/box3d-predicates

Conversation

@jiayuasu
Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

  • Yes — closes #3012; part of the Box3D Phase 1 epic (#2973).

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 &&& 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 a future antimeridian-wraparound convention — Z has no wraparound semantics, so all three axes share the same strict ordering requirement.
  • ST_3DBoxIntersects / ST_3DBoxContains Catalyst case classes wired through InferredExpression and registered in the Catalog.

How was this patch tested?

  • New Java unit tests in 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.
  • New ScalaTest suite Box3DPredicateSuite covering the SQL surface end-to-end. 4 tests, all green locally.

Did this PR include necessary documentation updates?

  • No — docs land alongside the final Phase 1 slice once the full surface (predicates + aggregate) is in place.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.box3dIntersects and Predicates.box3dContains in Java common, with shared requireOrderedBox3D helper.
  • Adds Catalyst ST_3DBoxIntersects / ST_3DBoxContains case classes via InferredExpression and registers them under predicateExprs in Catalog.
  • Adds Java unit tests in PredicatesTest and a new Box3DPredicateSuite SQL 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).
@jiayuasu jiayuasu force-pushed the feature/box3d-predicates branch from 37b9d82 to ab970ce Compare May 30, 2026 03:25
@jiayuasu jiayuasu linked an issue May 30, 2026 that may be closed by this pull request
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone May 30, 2026
@jiayuasu jiayuasu merged commit 5f40925 into apache:master May 30, 2026
44 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.

Box3D predicates: ST_3DBoxIntersects and ST_3DBoxContains

2 participants