jiayuasu opened a new pull request, #3035:
URL: https://github.com/apache/sedona/pull/3035

   ## Did you read the Contributor Guide?
   
   - [x] Yes
   
   ## Is this PR related to a ticket?
   
   - [x] Yes — closes [#3034](https://github.com/apache/sedona/issues/3034); 
follow-up to the Box3D EPIC 
([#2973](https://github.com/apache/sedona/issues/2973)).
   
   ## What changes were proposed in this PR?
   
   `ST_3DDWithin` was unplanned, so 3D distance joins ran as O(n × m) 
row-by-row evaluation. This PR wires both inferrable branches into the existing 
indexed distance-join pipeline.
   
   **Approach** — same XY-projection trick as #3032 (Box3D `ST_Intersects` / 
`ST_Contains`), applied to the distance-join path. Correctness rests on the 
inequality `|A_XY − B_XY|_2 ≤ |A − B|_3D`, so expanding each XY rectangle by 
`distance` and probing the 2D R-tree is a valid superset filter; the actual 3D 
refine runs at the per-pair condition step.
   
   - `JoinQueryDetector`: new arm for `ST_3DDWithin(Seq(left, right, d))` that 
produces a `JoinQueryDetection` with `SpatialPredicate.INTERSECTS` for the 
distance-expanded envelope R-tree pass, `condition` (the full original join 
condition) as the per-pair filter, and `distance = Some(d)` so the executor 
builds the expanded envelope. Routes both overloads through the same plan — 
Geometry inputs land on the JTS envelope; Box3D inputs land on the XY footprint 
already materialised in `TraitJoinQueryBase.shapeToGeometry` by #3032. EXPLAIN 
output adds an `ST_3DDWithin` label.
   - `OptimizableJoinCondition`: add `ST_3DDWithin` to the whitelist of 
distance-join predicates so `isDistanceJoinOptimizable` accepts it (parallel to 
the existing `ST_DWithin` entry).
   - No changes to `TraitJoinQueryBase` required — Box3D's XY-footprint 
materialisation already lives there from #3032, and `toExpandedEnvelopeRDD` 
already calls into it.
   
   **ST_3DDWithin has no Geography overload**, so no Geography branching is 
needed in the new arm (the analyzer would reject Geography input upstream).
   
   ## How was this patch tested?
   
   - New `Box3DDWithinJoinSuite` covers broadcast index distance join, 
non-broadcast `DistanceJoinExec`, the closed-interval threshold edge, and a 
discriminating row that is XY-overlapping with the left side but Z=99 away — 
the 2D R-tree pairs it via XY-expansion, the 3D refine rejects it. Also a 
Geometry-input case (POINT Z) that exercises the same indexed plan via the 
Geometry overload.
   - Full sweep on `Box3DDWithinJoinSuite` + `Box3DJoinSuite` + 
`Box3DDWithinSuite` + `Box2DJoinSuite`: 30 tests pass locally.
   
   ## Did this PR include necessary documentation updates?
   
   - [x] No — Box3D documentation is tracked separately under the Box3D EPIC.


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

Reply via email to