cloud-fan commented on a change in pull request #32192:
URL: https://github.com/apache/spark/pull/32192#discussion_r614189392



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1490,14 +1490,18 @@ class Analyzer(override val catalogManager: 
CatalogManager)
               case UpdateAction(updateCondition, assignments) =>
                 val resolvedUpdateCondition = updateCondition.map(
                   resolveExpressionByPlanChildren(_, m))
-                // The update value can access columns from both target and 
source tables.
                 UpdateAction(
                   resolvedUpdateCondition,
-                  resolveAssignments(Some(assignments), m, 
resolveValuesWithSourceOnly = false))
+                  // The update value can access columns from both target and 
source tables.
+                  resolveAssignments(assignments, m, 
resolveValuesWithSourceOnly = false))
               case UpdateStarAction(updateCondition) =>
+                val assignments = targetTable.output.map { attr =>
+                  Assignment(attr, UnresolvedAttribute(Seq(attr.name)))
+                }
                 UpdateAction(
                   updateCondition.map(resolveExpressionByPlanChildren(_, m)),
-                  resolveAssignments(assignments = None, m, 
resolveValuesWithSourceOnly = false))
+                  // For UPDATE *, the value must from source table.
+                  resolveAssignments(assignments, m, 
resolveValuesWithSourceOnly = true))

Review comment:
       To avoid resolving `UpdateAction` again with 
`resolveValuesWithSourceOnly = false` in the next analysis round, I added 
`resolveMergeExprOrFail` to fail earlier if an attribute can't be resolved.




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



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

Reply via email to