miland-db commented on code in PR #58606:
URL: https://github.com/apache/spark/pull/58606#discussion_r3956145126


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveIdentifierClause.scala:
##########
@@ -110,16 +125,13 @@ class ResolveIdentifierClause(earlyBatches: 
Seq[RuleExecutor[LogicalPlan]#Batch]
     collectTempVars(child)
   }
 
+  // Visits `child` itself as well as its descendants, so that an identifier 
expression which is
+  // just a variable reference is collected too.
   private def collectTemporaryVariablesInExpressionTree(child: Expression): 
Seq[Seq[String]] = {
-    def collectTempVars(child: Expression): Seq[Seq[String]] = {
-      child.flatMap { expr =>
-        expr.children.flatMap(_.flatMap {
-          case e: SubqueryExpression => 
collectTemporaryVariablesInLogicalPlan(e.plan)
-          case r: VariableReference => Seq(r.originalNameParts)
-          case _ => Seq.empty
-        })
-      }.distinct
-    }
-    collectTempVars(child)
+    child.flatMap {
+      case e: SubqueryExpression => 
collectTemporaryVariablesInLogicalPlan(e.plan)
+      case r: VariableReference => Seq(r.originalNameParts)
+      case _ => Seq.empty
+    }.distinct

Review Comment:
   Is this change needed for the fix?



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