You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2026/07/02 05:23:21 UTC

(sedona) branch master updated: [GH-3089] Fix empty-envelope false candidate and RS_DWithin EXPLAIN label in raster distance join (#3090)

This is an automated email from the ASF dual-hosted git repository.

jiayuasu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new 45aa2eaa9b [GH-3089] Fix empty-envelope false candidate and RS_DWithin EXPLAIN label in raster distance join (#3090)
45aa2eaa9b is described below

commit 45aa2eaa9b0f94860858e7e1b02b0542dad64480
Author: Jia Yu <ji...@apache.org>
AuthorDate: Wed Jul 1 22:23:16 2026 -0700

    [GH-3089] Fix empty-envelope false candidate and RS_DWithin EXPLAIN label in raster distance join (#3090)
---
 .../spark/sql/sedona_sql/strategy/join/BroadcastIndexJoinExec.scala | 2 +-
 .../spark/sql/sedona_sql/strategy/join/TraitJoinQueryBase.scala     | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/BroadcastIndexJoinExec.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/BroadcastIndexJoinExec.scala
index c210debb74..f67fea76f0 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/BroadcastIndexJoinExec.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/BroadcastIndexJoinExec.scala
@@ -122,7 +122,7 @@ case class BroadcastIndexJoinExec(
     case (None, _, false) => s"ST_$spatialPredicate($windowExpression, $objectExpression)"
     case (None, _, true) => s"RS_$spatialPredicate($windowExpression, $objectExpression)"
     case (Some(r), _, true) =>
-      s"RS_Distance($windowExpression, $objectExpression) < $r"
+      s"RS_DWithin($windowExpression, $objectExpression, $r)"
   }
 
   override def simpleString(maxFields: Int): String =
diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/TraitJoinQueryBase.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/TraitJoinQueryBase.scala
index c59c4f464a..99e3149873 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/TraitJoinQueryBase.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/TraitJoinQueryBase.scala
@@ -188,6 +188,12 @@ trait TraitJoinQueryBase {
   private[join] def expandRasterFilterEnvelope(
       baseShape: Geometry,
       distance: Double): Geometry = {
+    // An empty shape (e.g. the empty GeometryCollection substituted for a NULL raster/geometry)
+    // must stay empty: expanding its degenerate envelope by `distance` would yield a non-empty
+    // filter geometry that spuriously matches rows the predicate should never join.
+    if (baseShape.isEmpty) {
+      return baseShape
+    }
     val envelope = baseShape.getEnvelopeInternal
     val touchesPole = envelope.getMaxY >= 90.0 || envelope.getMinY <= -90.0
     val tooWide = envelope.getWidth > 180.0