cloud-fan commented on code in PR #38400:
URL: https://github.com/apache/spark/pull/38400#discussion_r1009082879


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -1583,21 +1599,20 @@ class Analyzer(override val catalogManager: 
CatalogManager)
     def resolveAssignments(
         assignments: Seq[Assignment],
         mergeInto: MergeIntoTable,
-        resolveValuesWithSourceOnly: Boolean): Seq[Assignment] = {
+        resolveValuesFrom: LogicalPlan): Seq[Assignment] = {
       assignments.map { assign =>
         val resolvedKey = assign.key match {
           case c if !c.resolved =>
             resolveMergeExprOrFail(c, Project(Nil, mergeInto.targetTable))
           case o => o
         }
         val resolvedValue = assign.value match {
-          // The update values may contain target and/or source references.
           case c if !c.resolved =>
-            if (resolveValuesWithSourceOnly) {
-              resolveMergeExprOrFail(c, Project(Nil, mergeInto.sourceTable))
-            } else {
-              resolveMergeExprOrFail(c, mergeInto)
+            val resolveFromChildren = resolveValuesFrom match {
+              case m: MergeIntoTable => m
+              case p => Project(Nil, p)

Review Comment:
   this pattern match looks a bit hacky. How about adding a new method?
   ```
   def resolveAssignmentsByPlanOutput ... {
     resolveAssignments(..., Project(Nil, p))
   }
   ```



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to