You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "zhangfengcdt (via GitHub)" <gi...@apache.org> on 2026/10/13 15:57:17 UTC

[I] sedona-spatial-join: GEOS refiner evaluates Within/CoveredBy reversed in PrepareProbe mode [sedona-db]

zhangfengcdt opened a new issue, #1435:
URL: https://github.com/apache/sedona-db/issues/1435

   ### Summary
   
   `GeosRefiner` evaluates `Within` and `CoveredBy` in the opposite direction when it runs in `ExecutionMode::PrepareProbe`. The mode selector always chooses `PrepareProbe` for those two predicates, so a relation join on `Within` or `CoveredBy` that uses the GEOS refiner returns `probe within build` instead of `build within probe`.
   
   ### Details (at e71330fb1)
   
   `rust/sedona-spatial-join/src/refine/geos.rs`, the `impl_geos_evaluator!` macro (around lines 509–555):
   
   - `evaluate` → `build_geom.$geos_method(probe)`, i.e. **build ⟨pred⟩ probe**
   - `evaluate_prepare_build` → `prepared_build.$geos_method(probe)`, i.e. **build ⟨pred⟩ probe**
   - `evaluate_prepare_probe` → `prepared_probe.$geos_method(&build_geom)`, i.e. **probe ⟨pred⟩ build**, the reverse
   
   The reversal makes no difference for symmetric predicates (`intersects`, `touches`, `crosses`, `overlaps`). For `within` and `covered_by` it inverts the result.
   
   `GeosOptimalModeSelector::select_without_probe_stats` (around lines 106–108) picks `PrepareProbe` for `Within | CoveredBy`, so that inverted path is the one used for them.
   
   ### How we hit it
   
   We use `SpatialJoinExec` with a custom `SpatialJoinProvider` that pins the refiner library to GEOS, and a `RelationPredicate(build, probe, Within)`. Results came out inverted, as if the relation were `Contains`, until we forced `ExecutionMode::PrepareNone` for `Within`/`CoveredBy`. If sedona-db's own planner never produces `Within`/`CoveredBy` relation predicates for the GEOS refiner, this may be latent. It is still wrong for any other caller.
   
   ### Suggested fix
   
   In `evaluate_prepare_probe`, evaluate the converse predicate on the prepared probe geometry:
   - `within` ↔ `contains`
   - `covered_by` ↔ `covers`
   - symmetric predicates unchanged
   
   Or select `PrepareNone`/`PrepareBuild` for `Within`/`CoveredBy`. Add tests that compare each mode against `evaluate` for every relation type.


-- 
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: issues-unsubscribe@sedona.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] sedona-spatial-join: GEOS refiner evaluates Within/CoveredBy reversed in PrepareProbe mode [sedona-db]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot closed issue #1435: sedona-spatial-join: GEOS refiner evaluates Within/CoveredBy reversed in PrepareProbe mode
URL: https://github.com/apache/sedona-db/issues/1435


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org