Skip to content

Commit 1340862

Browse files
committed
Move some rules into postHocResolutionRules
1 parent 7b32f46 commit 1340862

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ class Analyzer(
112112
* in an individual batch. This batch is to run right after the normal resolution batch and
113113
* execute its rules in one pass.
114114
*/
115-
val postHocResolutionRules: Seq[Rule[LogicalPlan]] = Nil
115+
def postHocResolutionRules: Seq[Rule[LogicalPlan]] =
116+
ResolveOrdinalInOrderByAndGroupBy ::
117+
ResolveAggAliasInGroupBy ::
118+
ResolveMissingReferences ::
119+
ResolveSubquery ::
120+
ResolveAggregateFunctions ::
121+
Nil
116122

117123
lazy val batches: Seq[Batch] = Seq(
118124
Batch("Hints", fixedPoint,
@@ -135,9 +141,6 @@ class Analyzer(
135141
ResolveUpCast ::
136142
ResolveGroupingAnalytics ::
137143
ResolvePivot ::
138-
ResolveOrdinalInOrderByAndGroupBy ::
139-
ResolveAggAliasInGroupBy ::
140-
ResolveMissingReferences ::
141144
ExtractGenerator ::
142145
ResolveGenerate ::
143146
ResolveFunctions ::
@@ -148,13 +151,12 @@ class Analyzer(
148151
ResolveNaturalAndUsingJoin ::
149152
ExtractWindowExpressions ::
150153
GlobalAggregates ::
151-
ResolveAggregateFunctions ::
152154
TimeWindowing ::
153155
ResolveInlineTables(conf) ::
154156
ResolveTimeZone(conf) ::
155157
TypeCoercion.typeCoercionRules ++
156158
extendedResolutionRules : _*),
157-
Batch("Post-Hoc Resolution", Once, postHocResolutionRules: _*),
159+
Batch("Post-Hoc Resolution", fixedPoint, postHocResolutionRules: _*),
158160
Batch("View", Once,
159161
AliasViewChild(conf)),
160162
Batch("Nondeterministic", Once,

sql/core/src/main/scala/org/apache/spark/sql/internal/BaseSessionStateBuilder.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ abstract class BaseSessionStateBuilder(
161161
customResolutionRules
162162

163163
override val postHocResolutionRules: Seq[Rule[LogicalPlan]] =
164-
PreprocessTableCreation(session) +:
165-
PreprocessTableInsertion(conf) +:
166-
DataSourceAnalysis(conf) +:
167-
customPostHocResolutionRules
164+
super.postHocResolutionRules ++ (
165+
PreprocessTableCreation(session) +:
166+
PreprocessTableInsertion(conf) +:
167+
DataSourceAnalysis(conf) +:
168+
customPostHocResolutionRules)
168169

169170
override val extendedCheckRules: Seq[LogicalPlan => Unit] =
170171
PreWriteCheck +:

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionStateBuilder.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ class HiveSessionStateBuilder(session: SparkSession, parentState: Option[Session
7474
customResolutionRules
7575

7676
override val postHocResolutionRules: Seq[Rule[LogicalPlan]] =
77-
new DetermineTableStats(session) +:
78-
RelationConversions(conf, catalog) +:
79-
PreprocessTableCreation(session) +:
80-
PreprocessTableInsertion(conf) +:
81-
DataSourceAnalysis(conf) +:
82-
HiveAnalysis +:
83-
customPostHocResolutionRules
77+
super.postHocResolutionRules ++ (
78+
new DetermineTableStats(session) +:
79+
RelationConversions(conf, catalog) +:
80+
PreprocessTableCreation(session) +:
81+
PreprocessTableInsertion(conf) +:
82+
DataSourceAnalysis(conf) +:
83+
HiveAnalysis +:
84+
customPostHocResolutionRules)
8485

8586
override val extendedCheckRules: Seq[LogicalPlan => Unit] =
8687
PreWriteCheck +:

0 commit comments

Comments
 (0)