yyanyy commented on code in PR #59662:
URL: https://github.com/apache/spark/pull/59662#discussion_r4365406704


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/planmerging/PlanMerger.scala:
##########
@@ -903,7 +903,10 @@ class PlanMerger(
     // here: SPARK-58207 keeps non-deterministic filters from being pushed to 
a V2 source, so an
     // offered one is simply not pushed (and dropped when the scan is 
extracted).
     val conds = strictFilters ++ 
bestEffortFilter.filter(_.references.subsetOf(relationOut))
-    V2ScanRelationPushDown.rebuildScan(relation, unionAttrs, conds).filter { 
scan =>
+    // Spark reads the merged result through scalar subqueries, even when the 
original
+    // scans came from the main query. Rebuild the scan with the destination's 
context.
+    V2ScanRelationPushDown.rebuildScan(
+      relation, unionAttrs, conds, isSubquery = true).filter { scan =>

Review Comment:
   Updated the documentation



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to