Skip to content

Commit 5dab65a

Browse files
committed
Fix
1 parent f24e82d commit 5dab65a

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ class Analyzer(
132132
override val catalogManager: CatalogManager,
133133
conf: SQLConf,
134134
maxIterations: Int)
135-
extends RuleExecutor[LogicalPlan] with CheckAnalysis with LookupCatalog
136-
with LogicalPlanIntegrity {
135+
extends RuleExecutor[LogicalPlan] with CheckAnalysis with LookupCatalog {
137136

138137
private val v1SessionCatalog: SessionCatalog = catalogManager.v1SessionCatalog
139138

140139
override protected def isPlanIntegral(plan: LogicalPlan): Boolean = {
141-
!Utils.isTesting || hasUniqueIdsForAttributes(plan)
140+
!Utils.isTesting || LogicalPlanIntegrity.hasUniqueExprIdsForAttributes(plan)
142141
}
143142

144143
override def isView(nameParts: Seq[String]): Boolean = v1SessionCatalog.isView(nameParts)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import org.apache.spark.util.Utils
3737
* Optimizers can override this.
3838
*/
3939
abstract class Optimizer(catalogManager: CatalogManager)
40-
extends RuleExecutor[LogicalPlan] with LogicalPlanIntegrity {
40+
extends RuleExecutor[LogicalPlan] {
4141

4242
// Check for structural integrity of the plan in test mode.
4343
// Currently we check after the execution of each rule if a plan:
@@ -46,7 +46,7 @@ abstract class Optimizer(catalogManager: CatalogManager)
4646
override protected def isPlanIntegral(plan: LogicalPlan): Boolean = {
4747
!Utils.isTesting || (plan.resolved &&
4848
plan.find(PlanHelper.specialExpressionsInUnsupportedOperator(_).nonEmpty).isEmpty) &&
49-
hasUniqueIdsForAttributes(plan)
49+
LogicalPlanIntegrity.hasUniqueExprIdsForAttributes(plan)
5050
}
5151

5252
override protected val excludedOnceBatches: Set[String] =

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ abstract class OrderPreservingUnaryNode extends UnaryNode {
204204
override final def outputOrdering: Seq[SortOrder] = child.outputOrdering
205205
}
206206

207-
trait LogicalPlanIntegrity {
207+
object LogicalPlanIntegrity {
208208

209209
private def canGetOutputAttrs(p: LogicalPlan): Boolean = {
210210
p.resolved && !p.expressions.exists { e =>
@@ -214,7 +214,12 @@ trait LogicalPlanIntegrity {
214214
}
215215
}
216216

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 = {
218223
val allOutputAttrs = plan.collect { case p if canGetOutputAttrs(p) =>
219224
p.output.filter(_.resolved).map(_.canonicalized.asInstanceOf[Attribute])
220225
}

0 commit comments

Comments
 (0)