Skip to content

[GH-2973] Box3D foundation: value class + UDT + Catalyst plumbing#2978

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

[GH-2973] Box3D foundation: value class + UDT + Catalyst plumbing#2978
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:feature/box3d-foundation

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?

Foundation slice for the Box3D type. Lands the value class and the UDT so the rest of Phase 1 can be reviewed independently.

What's in this PR

  • Box3D value class in common/.../geometryObjects/Box3D.java. Stores six doubles in PostGIS box3d order: xmin, ymin, zmin, xmax, ymax, zmax. 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.
  • Box3DUDT (struct of six non-nullable doubles) + UDT registration via UdtRegistratorWrapper.
  • Catalyst plumbing in InferredExpression: Box3D as an InferrableType, with the matching argument-extractor, serializer, and Spark DataType mapping (Box3DUDT()).
  • implicits.toBox3D extension method to deserialise a Box3D from an InternalRow.
  • Box3DUDTSuite covering: registration via UdtRegistratorWrapper, JSON schema round-trip, UDT serialize/deserialize, case-object equality with a fresh instance, and Parquet write/read.

What's not in this PR

Everything else from Phase 1 lands as separate slices on the same issue:

Slice Scope
#2 ST_Box3D(geom) + ST_3DMakeBox(p1, p2)
#3 ST_XMin/YMin/ZMin/XMax/YMax/ZMax(box3d) overloads + ST_AsText(box3d)
#4 ST_3DBoxIntersects / ST_3DBoxContains
#5 ST_3DExtent aggregate

How was this patch tested?

  • Box3DUDTSuite — 5 tests, all passing locally on Spark 3.5 / Scala 2.12.
  • Full compile of spark/common clean with the new type wired through Catalyst.

Did this PR include necessary documentation updates?

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

First slice of the Box3D Phase 1 epic. Lays down the value class and
the UDT so subsequent slices (scalar constructors, accessors, predicates,
aggregate) can be reviewed independently.

- `Box3D` value class in `common` (six doubles in PostGIS order:
  xmin, ymin, zmin, xmax, ymax, zmax). NaN-Z folds into the z=0 plane
  per coordinate, matching PostGIS's flat-XY-treated-as-XY[Z=0]
  convention.
- `Box3DUDT` (struct of six non-nullable doubles) + UDT registration
  via `UdtRegistratorWrapper`.
- Catalyst plumbing in `InferredExpression`: Box3D as an
  `InferrableType` with matching argument-extractor, serializer, and
  Spark-DataType paths.
- `implicits.toBox3D` extension method to deserialise a Box3D from an
  InternalRow.
- `Box3DUDTSuite`: UDT round-trip, JSON schema, and Parquet write/read.

No new SQL functions yet — those land in follow-up slices on this same
issue. Phase 1 is split into 5 PRs (foundation, constructors, accessors
+ AsText, predicates, ST_3DExtent aggregate) to keep each review small.
@jiayuasu jiayuasu force-pushed the feature/box3d-foundation branch from c11f0a8 to fbb3571 Compare May 22, 2026 06:19
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone May 22, 2026
@jiayuasu jiayuasu linked an issue May 22, 2026 that may be closed by this pull request
10 tasks
@jiayuasu jiayuasu merged commit b5c1635 into apache:master May 22, 2026
44 checks passed
@jiayuasu jiayuasu deleted the feature/box3d-foundation branch May 22, 2026 07:10
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.

Add a native Box3D type for 3D bounding boxes (PostGIS-compatible)

2 participants