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

 ##########
 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:
   The insert condition also has to be resolved only on the source, and not on 
the target. I had the same mistake in my Delta merge as well! This bug made me 
double-check my own implementation in Delta.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to