[GH-2973] Box3D accessors + ST_AsText overload#3005
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Box3D accessor support to the Spark SQL expression layer and exposes a PostGIS-style BOX3D(...) text form via ST_AsText, with a new ScalaTest suite validating behavior.
Changes:
- Added
Functions.{xMin,yMin,zMin,xMax,yMax,zMax}(Box3D)overloads andFunctions.box3dAsText(Box3D)incommon. - Extended Catalyst
InferredExpressiondispatch soST_XMin/YMin/ZMin/XMax/YMax/ZMaxandST_AsTextacceptBox3D. - Added
Box3DAccessorSuitecovering accessors, null propagation, andST_AsText(box3d)formatting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| spark/common/src/test/scala/org/apache/sedona/sql/Box3DAccessorSuite.scala | Adds tests for Box3D accessors and ST_AsText(Box3D) behavior. |
| spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala | Extends expression dispatch to support Box3D in accessors and ST_AsText. |
| common/src/main/java/org/apache/sedona/common/Functions.java | Adds Box3D accessor overloads and box3dAsText implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+98
to
+102
| * This function takes a geometry and returns the maximum of all Z-coordinate values. | ||
| */ | ||
| private[apache] case class ST_ZMax(inputExpressions: Seq[Expression]) | ||
| extends InferredExpression(Functions.zMax _) { | ||
| extends InferredExpression( | ||
| inferrableFunction1((g: Geometry) => Functions.zMax(g)), |
Comment on lines
+114
to
+118
| * This function takes a geometry and returns the minimum of all Z-coordinate values. | ||
| */ | ||
| private[apache] case class ST_ZMin(inputExpressions: Seq[Expression]) | ||
| extends InferredExpression(Functions.zMin _) { | ||
| extends InferredExpression( | ||
| inferrableFunction1((g: Geometry) => Functions.zMin(g)), |
|
|
||
| /** | ||
| * PostGIS-format text for a Box3D: {@code BOX3D(xmin ymin zmin, xmax ymax zmax)}. NULL on null | ||
| * input. Like {@link #box2dAsText(Box2D)} this is not WKT (WKT has no {@code BOX3D} type) and |
Third slice of the Box3D Phase 1 epic. Builds on the type + constructors
from the previous slices.
- `Functions.{xMin,yMin,zMin,xMax,yMax,zMax}(Box3D)` Java overloads —
each returns the corresponding bound from the Box3D struct.
- `Functions.box3dAsText(Box3D)` — PostGIS-format text form
`BOX3D(xmin ymin zmin, xmax ymax zmax)`. Not WKT; lives alongside the
Box2D `BOX(...)` text form rather than inside the `asWKT` family.
- Catalyst case classes `ST_XMin/YMin/ZMin/XMax/YMax/ZMax` and
`ST_AsText` extended with `inferrableFunction1((b: Box3D) => ...)`
entries so Spark dispatches by argument type.
- `Box3DAccessorSuite`: covers all six accessors, NULL-input propagation,
ST_AsText output format, and ST_AsText NULL propagation.
Remaining slices: predicates (ST_3DBoxIntersects / ST_3DBoxContains)
and ST_3DExtent aggregate.
a04bf45 to
666218c
Compare
10 tasks
This was referenced May 29, 2026
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?
[GH-XXX] my subject.What changes were proposed in this PR?
Third slice of the Box3D Phase 1 epic (#2973). Builds on the type + constructors merged in #2978 and #2984.
Functions.{xMin, yMin, zMin, xMax, yMax, zMax}(Box3D)Java overloads — each returns the corresponding bound from the Box3D struct.Functions.box3dAsText(Box3D)— PostGIS-format text formBOX3D(xmin ymin zmin, xmax ymax zmax). Not WKT; lives alongside the existing Box2DBOX(...)text form rather than inside theasWKTfamily.InferredExpression:ST_XMin/YMin/ZMin/XMax/YMax/ZMaxgaininferrableFunction1((b: Box3D) => ...)branches;ST_AsTextis extended with a Box3D overload so the same accessor names work for geometry, Box2D, and Box3D.Box3DAccessorSuite: covers all six accessors, NULL-input propagation, ST_AsText output format, and ST_AsText NULL propagation.Remaining Phase 1 slices: predicates (ST_3DBoxIntersects / ST_3DBoxContains) and the ST_3DExtent aggregate.
How was this patch tested?
Box3DAccessorSuite(4 tests, all green locally).mvn -pl spark/common -Dspark=3.5 -Dscala=2.12 testcovering the affected expression layer.Did this PR include necessary documentation updates?