zhangfengcdt commented on code in PR #2871:
URL: https://github.com/apache/sedona/pull/2871#discussion_r3171535662


##########
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinQueryDetector.scala:
##########
@@ -843,9 +886,20 @@ class JoinQueryDetector(sparkSession: SparkSession) 
extends SparkStrategy {
       .map { distanceExpr =>
         matchDistanceExpressionToJoinSide(distanceExpr, left, right) match {
           case Some(side) =>
-            if (broadcastSide.get == side) (Some(distanceExpr), None)
-            else if (distanceExpr.references.isEmpty) (Some(distanceExpr), 
None)
-            else (None, Some(distanceExpr))
+            if (geographyShape) {
+              // Geography distance joins read the per-row radius from the 
stream-side
+              // GeographyJoinShape inside GeographyDistanceRefiner, so the 
radius MUST
+              // also flow to the stream side. For literal radii we still keep 
the
+              // build-side expansion (mirror of the geometry literal 
optimisation).
+              if (broadcastSide.get == side) (Some(distanceExpr), 
Some(distanceExpr))
+              else if (distanceExpr.references.isEmpty)
+                (Some(distanceExpr), Some(distanceExpr))
+              else (None, Some(distanceExpr))

Review Comment:
   Restructured into three explicit branches.



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