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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -520,9 +532,41 @@ trait ColumnResolutionHelper extends Logging with 
DataTypeErrorsBase {
             "planId" -> planId.toString,
             "q" -> q.toString))
       }
-    })
+      if (resolved.length > 1) {
+        throw new AnalysisException(
+          errorClass = "AMBIGUOUS_COLUMN_REFERENCE",
+          messageParameters = Map("name" -> toSQLId(u.nameParts)),
+          origin = u.origin
+        )
+      }
+      resolved.headOption
+    }
+  }
 
-    val isMetadataAccess = u.getTagValue(LogicalPlan.IS_METADATA_COL).isDefined
+  private def resolveUnresolvedAttributeByPlanId(

Review Comment:
   we should merge this with the other `resolveUnresolvedAttributeByPlanId`. 
The overall algorithm should be
   1. bottom-up traverse the plan tree to find the matching df plan.
   2. resolve the column and propogate it up
   3. during propogation, prune the resolved columns with plan's output. It 
should happen for each plan node, not just the top plan node's children.



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