Skip to content

Commit 7040877

Browse files
committed
[SPARK-21103][SQL] QueryPlanConstraints should be part of LogicalPlan
1 parent fffeb6d commit 7040877

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ import org.apache.spark.sql.catalyst.trees.TreeNode
2222
import org.apache.spark.sql.internal.SQLConf
2323
import org.apache.spark.sql.types.{DataType, StructType}
2424

25-
abstract class QueryPlan[PlanType <: QueryPlan[PlanType]]
26-
extends TreeNode[PlanType]
27-
with QueryPlanConstraints[PlanType] {
28-
25+
abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanType] {
2926
self: PlanType =>
3027

3128
def conf: SQLConf = SQLConf.get

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import org.apache.spark.sql.internal.SQLConf
2727
import org.apache.spark.sql.types.StructType
2828

2929

30-
abstract class LogicalPlan extends QueryPlan[LogicalPlan] with Logging {
30+
abstract class LogicalPlan extends QueryPlan[LogicalPlan] with QueryPlanConstraints with Logging {
3131

3232
private var _analyzed: Boolean = false
3333

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlanConstraints.scala renamed to sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql.catalyst.plans
18+
package org.apache.spark.sql.catalyst.plans.logical
1919

2020
import org.apache.spark.sql.catalyst.expressions._
2121

2222

23-
trait QueryPlanConstraints[PlanType <: QueryPlan[PlanType]] { self: QueryPlan[PlanType] =>
23+
trait QueryPlanConstraints { self: LogicalPlan =>
2424

2525
/**
2626
* An [[ExpressionSet]] that contains invariants about the rows output by this operator. For
@@ -99,7 +99,8 @@ trait QueryPlanConstraints[PlanType <: QueryPlan[PlanType]] { self: QueryPlan[Pl
9999
private lazy val aliasMap: AttributeMap[Expression] = AttributeMap(
100100
expressions.collect {
101101
case a: Alias => (a.toAttribute, a.child)
102-
} ++ children.flatMap(_.asInstanceOf[QueryPlanConstraints[PlanType]].aliasMap))
102+
} ++ children.flatMap(_.asInstanceOf[QueryPlanConstraints].aliasMap))
103+
// Note: the explicit cast is necessary, since Scala compiler fails to infer the type.
103104

104105
/**
105106
* Infers an additional set of constraints from a given set of equality constraints.

0 commit comments

Comments
 (0)