Skip to content

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

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

[GH-2973] Box3D foundation: value class + UDT + Catalyst plumbing#2978
jiayuasu wants to merge 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?

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.
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.

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.

2 participants