File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -132,13 +132,12 @@ class Analyzer(
132
132
override val catalogManager : CatalogManager ,
133
133
conf : SQLConf ,
134
134
maxIterations : Int )
135
- extends RuleExecutor [LogicalPlan ] with CheckAnalysis with LookupCatalog
136
- with LogicalPlanIntegrity {
135
+ extends RuleExecutor [LogicalPlan ] with CheckAnalysis with LookupCatalog {
137
136
138
137
private val v1SessionCatalog : SessionCatalog = catalogManager.v1SessionCatalog
139
138
140
139
override protected def isPlanIntegral (plan : LogicalPlan ): Boolean = {
141
- ! Utils .isTesting || hasUniqueIdsForAttributes (plan)
140
+ ! Utils .isTesting || LogicalPlanIntegrity .hasUniqueExprIdsForAttributes (plan)
142
141
}
143
142
144
143
override def isView (nameParts : Seq [String ]): Boolean = v1SessionCatalog.isView(nameParts)
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ import org.apache.spark.util.Utils
37
37
* Optimizers can override this.
38
38
*/
39
39
abstract class Optimizer (catalogManager : CatalogManager )
40
- extends RuleExecutor [LogicalPlan ] with LogicalPlanIntegrity {
40
+ extends RuleExecutor [LogicalPlan ] {
41
41
42
42
// Check for structural integrity of the plan in test mode.
43
43
// Currently we check after the execution of each rule if a plan:
@@ -46,7 +46,7 @@ abstract class Optimizer(catalogManager: CatalogManager)
46
46
override protected def isPlanIntegral (plan : LogicalPlan ): Boolean = {
47
47
! Utils .isTesting || (plan.resolved &&
48
48
plan.find(PlanHelper .specialExpressionsInUnsupportedOperator(_).nonEmpty).isEmpty) &&
49
- hasUniqueIdsForAttributes (plan)
49
+ LogicalPlanIntegrity .hasUniqueExprIdsForAttributes (plan)
50
50
}
51
51
52
52
override protected val excludedOnceBatches : Set [String ] =
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ abstract class OrderPreservingUnaryNode extends UnaryNode {
204
204
override final def outputOrdering : Seq [SortOrder ] = child.outputOrdering
205
205
}
206
206
207
- trait LogicalPlanIntegrity {
207
+ object LogicalPlanIntegrity {
208
208
209
209
private def canGetOutputAttrs (p : LogicalPlan ): Boolean = {
210
210
p.resolved && ! p.expressions.exists { e =>
@@ -214,7 +214,12 @@ trait LogicalPlanIntegrity {
214
214
}
215
215
}
216
216
217
- def hasUniqueIdsForAttributes (plan : LogicalPlan ): Boolean = {
217
+ /**
218
+ * This method checks if expression IDs, `ExprId`s, refer to unique attributes.
219
+ * Some plan transformers (e.g., `RemoveNoopOperators`) rewrite logical
220
+ * plans based on this assumption.
221
+ */
222
+ def hasUniqueExprIdsForAttributes (plan : LogicalPlan ): Boolean = {
218
223
val allOutputAttrs = plan.collect { case p if canGetOutputAttrs(p) =>
219
224
p.output.filter(_.resolved).map(_.canonicalized.asInstanceOf [Attribute ])
220
225
}
You can’t perform that action at this time.
0 commit comments