zhengruifeng commented on code in PR #45846:
URL: https://github.com/apache/spark/pull/45846#discussion_r1550680953


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -527,13 +527,15 @@ trait ColumnResolutionHelper extends Logging with 
DataTypeErrorsBase {
     logDebug(s"Extract plan_id $planId from $u")
 
     val isMetadataAccess = u.getTagValue(LogicalPlan.IS_METADATA_COL).nonEmpty
-    val (resolved, matched) = resolveDataFrameColumnByPlanId(u, planId, 
isMetadataAccess, q)
-    if (!matched) {
-      // Can not find the target plan node with plan id, e.g.
-      //  df1 = spark.createDataFrame([Row(a = 1, b = 2, c = 3)]])
-      //  df2 = spark.createDataFrame([Row(a = 1, b = 2)]])
-      //  df1.select(df2.a)   <-   illegal reference df2.a
-      throw QueryCompilationErrors.cannotResolveDataFrameColumn(u)
+    val resolved = resolveDataFrameColumnByPlanId(u, planId, isMetadataAccess, 
q, 0).map(_._1)
+    if (resolved.isEmpty) {
+      if 
(!q.exists(_.exists(_.getTagValue(LogicalPlan.PLAN_ID_TAG).contains(planId)))) {

Review Comment:
   I think there are two cases:
   
   1, analyzer rules supporting missing column resolution
   
   
https://github.com/apache/spark/blob/923f04606fe6bee5913f8fce7aaa643984f79756/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala#L583-L607
   
   2, plan id missed in some way (should be bugs)



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