@@ -38,7 +38,7 @@ import org.apache.spark.sql.catalyst.plans._
3838import org .apache .spark .sql .catalyst .plans .logical ._
3939import org .apache .spark .sql .catalyst .rules ._
4040import org .apache .spark .sql .catalyst .streaming .StreamingRelationV2
41- import org .apache .spark .sql .catalyst .trees .{ AlwaysProcess , CurrentOrigin }
41+ import org .apache .spark .sql .catalyst .trees .AlwaysProcess
4242import org .apache .spark .sql .catalyst .trees .CurrentOrigin .withOrigin
4343import org .apache .spark .sql .catalyst .trees .TreePattern ._
4444import org .apache .spark .sql .catalyst .util .{toPrettySQL , CharVarcharUtils , StringUtils }
@@ -1450,26 +1450,13 @@ class Analyzer(override val catalogManager: CatalogManager)
14501450 }
14511451 }
14521452
1453- def apply (plan : LogicalPlan ): LogicalPlan = {
1454- // To follow the behavior of `resolveOperators`, we return the input plan immediately if it's
1455- // already analyzed before.
1456- if (plan.analyzed) return plan
1457-
1458- val newPlan = plan.mapChildren(apply)
1459- if (newPlan.childrenResolved && ! hasConflictingAttrs(newPlan)) {
1460- CurrentOrigin .withOrigin(newPlan.origin) {
1461- val resolvedPlan = resolveColumns(newPlan)
1462- resolvedPlan.copyTagsFrom(newPlan)
1463- resolvedPlan
1464- }
1465- } else {
1466- // Wait for other rules to resolve child plans first, or wait for the rule
1467- // `DeduplicateRelations` to resolve conflicting attrs first.
1468- newPlan
1469- }
1470- }
1453+ def apply (plan : LogicalPlan ): LogicalPlan = plan.resolveOperatorsUp {
1454+ // Wait for other rules to resolve child plans first
1455+ case p : LogicalPlan if ! p.childrenResolved => p
1456+
1457+ // Wait for the rule `DeduplicateRelations` to resolve conflicting attrs first.
1458+ case p : LogicalPlan if hasConflictingAttrs(p) => p
14711459
1472- private def resolveColumns (plan : LogicalPlan ): LogicalPlan = plan match {
14731460 // If the projection list contains Stars, expand it.
14741461 case p : Project if containsStar(p.projectList) =>
14751462 p.copy(projectList = buildExpandedProjectList(p.projectList, p.child))
0 commit comments