jiayuasu opened a new pull request, #2932: URL: https://github.com/apache/sedona/pull/2932
## Did you read the Contributor Guide? - Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/) ## Is this PR related to a ticket? - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #2926 ## What changes were proposed in this PR? Adds two planar bbox predicates that operate on `Box2D` arguments: - `ST_BoxIntersects(a: Box2D, b: Box2D) -> Boolean` — true if the two bboxes share any point on either axis. Mirrors PostGIS `&&` on `box2d`. - `ST_BoxContains(a: Box2D, b: Box2D) -> Boolean` — true if `a` fully contains `b`. Mirrors PostGIS `~` on `box2d`. Both use **closed intervals**, matching PostGIS semantics — edge-touching and corner-touching count as intersection; equal boxes contain each other. NULL on null input. ### Where the changes land | Layer | Change | |---|---| | `common/.../Predicates.java` | Two new helpers `boxIntersects(Box2D, Box2D)` and `boxContains(Box2D, Box2D)` | | `spark/common/.../expressions/Predicates.scala` | Two new `ST_BoxIntersects` / `ST_BoxContains` case classes | | `spark/common/.../UDF/Catalog.scala` | Register both in `predicateExprs` | | `spark/common/.../expressions/st_predicates.scala` | Scala DataFrame API wrappers (Column + String overloads) | | `python/sedona/spark/sql/st_predicates.py` | PySpark wrappers | | `flink/.../expressions/Predicates.java` | Two new ScalarFunction classes | | `flink/.../Catalog.java` | Register both | ## How was this patch tested? - `common/.../PredicatesTest.java` — `testBoxIntersects` (full overlap, partial overlap, edge-touching, corner-touching, disjoint X, disjoint Y) and `testBoxContains` (inside, equal, smaller-inside, outside, crosses-boundary). - `spark/common/.../predicateTestScala.scala` — "Passed ST_BoxIntersects and ST_BoxContains" — full SQL-level coverage of both predicates including NULL propagation. - `flink/.../PredicateTest.java` — `testBoxIntersects` and `testBoxContains` through Flink Table API. - `python/tests/sql/test_predicate.py` — `test_st_box_intersects_and_contains` through PySpark SQL. ## What's not in scope - **Mixed Box2D / Geometry predicates**. Users can wrap geometry inputs with `ST_Box2D(geom)` first. - **Spatial join planner integration** that uses Box2D predicates for partitioning. That's a separate optimizer change. - **3D box predicates** — wait for `Box3D` (#2928). ## Did this PR include necessary documentation updates? - No, this PR does not affect any public SQL API documentation surface in isolation. Documentation lands as part of the consolidated Phase 1+2 Box2D docs update once the remaining deferred follow-ups are scoped. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
