Skip to content

[GH-2973] Box3D constructors: ST_Box3D and ST_3DMakeBox#2984

Open
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:feature/box3d-constructors
Open

[GH-2973] Box3D constructors: ST_Box3D and ST_3DMakeBox#2984
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:feature/box3d-constructors

Conversation

@jiayuasu
Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

Adds the two scalar constructors that produce a Box3D from a Geometry or two corner points. Mirrors ST_Box2D / ST_MakeBox2D and PostGIS's Box3D(geometry) / ST_3DMakeBox.

  • Functions.box3D(geom): returns the 3D bbox of a Geometry. Geometries whose coordinates have NaN Z fold into the z = 0 plane on a per-coordinate basis, matching PostGIS's flat-XY-treated-as-XY[Z=0] convention.
  • Constructors.make3DBox(p1, p2): builds a Box3D from two corner POINTZ geometries. Missing-Z point inputs contribute z = 0. Non-POINT input raises IllegalArgumentException (same as ST_MakeBox2D).
  • ST_Box3D and ST_3DMakeBox Catalyst case classes wired through InferredExpression and registered in Catalog.boundingBoxExprs / Catalog.geometryConstructorExprs.

How was this patch tested?

Box3DConstructorSuite (5 tests, all passing locally on Spark 3.5 / Scala 2.12):

  • ST_Box3D on XY input (zmin/zmax = 0) and XYZ input.
  • ST_Box3D returns NULL for null and empty geometry input.
  • ST_3DMakeBox from two POINTZ corners.
  • ST_3DMakeBox from XY-only points (Z folds to zero).
  • ST_3DMakeBox returns NULL for null point input.

Did this PR include necessary documentation updates?

Second slice of the Box3D Phase 1 epic. Builds on the foundation
(value class + UDT + Catalyst plumbing) merged in the previous slice.

- `Functions.box3D(geom)`: returns the 3D bbox of a Geometry. Geometries
  whose coordinates have NaN Z fold into the z=0 plane (PostGIS-
  compatible).
- `Constructors.make3DBox(p1, p2)`: builds a Box3D from two corner
  POINTZ geometries; missing-Z points contribute z=0.
- `ST_Box3D` and `ST_3DMakeBox` Catalyst case classes wired through
  `InferredExpression`, registered in the Catalog.
- `Box3DConstructorSuite`: covers ST_Box3D for XY, XYZ, null, and
  empty inputs; ST_3DMakeBox for POINTZ, XY-only points (Z folds to
  zero), and null point input.

PostGIS-compatible semantics throughout. Phase 1 is split into 5 PRs;
remaining slices: accessors+AsText, predicates, ST_3DExtent aggregate.
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.

1 participant