cloud-fan commented on a change in pull request #27265: [SPARK-30555][SQL] 
MERGE INTO insert action should only access columns from source table
URL: https://github.com/apache/spark/pull/27265#discussion_r368494661
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ##########
 @@ -1326,13 +1326,20 @@ class Analyzer(
             DeleteAction(resolvedDeleteCondition)
           case UpdateAction(updateCondition, assignments) =>
             val resolvedUpdateCondition = 
updateCondition.map(resolveExpressionTopDown(_, m))
-            UpdateAction(resolvedUpdateCondition, 
resolveAssignments(assignments, m))
+            // The update value can access columns from both target and source 
tables.
+            UpdateAction(
+              resolvedUpdateCondition,
+              resolveAssignments(assignments, m, resolveValuesWithSourceOnly = 
false))
           case o => o
         }
         val newNotMatchedActions = m.notMatchedActions.map {
           case InsertAction(insertCondition, assignments) =>
             val resolvedInsertCondition = 
insertCondition.map(resolveExpressionTopDown(_, m))
 
 Review comment:
   good catch!

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to