vladimirg-db commented on code in PR #50548: URL: https://github.com/apache/spark/pull/50548#discussion_r2057965837
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala: ########## @@ -2320,20 +2348,57 @@ class Analyzer(override val catalogManager: CatalogManager) extends RuleExecutor e: SubqueryExpression, outer: LogicalPlan)( f: (LogicalPlan, Seq[Expression]) => SubqueryExpression): SubqueryExpression = { - val newSubqueryPlan = AnalysisContext.withOuterPlan(outer) { - executeSameContext(e.plan) + val outerPlanContext = AnalysisContext.get.outerPlans + val newSubqueryPlan = if (outerPlanContext.isDefined && + // We don't allow lateral subquery having nested correlation + !e.isInstanceOf[LateralSubquery] + ) { + // The previous outerPlanContext contains resolved outer scope plans Review Comment: I'm not sure about the claim that "the plan is guaranteed to be resolved". FIxed-point Analyzer loops the rules over the partially resolved plan, and the plan can be considered resolved only after the analysis is done, after `CheckAnalysis` (well, kinda, if you don't take all kinds of bugs into account). Which is different to the single-pass Analyzer, that guarantees that the tree that has been already traversed is properly 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. 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