Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ abstract class UnaryNode extends LogicalPlan {
override final def children: Seq[LogicalPlan] = child :: Nil

/**
* Generates an additional set of aliased constraints by replacing the original constraint
* expressions with the corresponding alias
* Generates all valid constraints including an set of aliased constraints by replacing the
* original constraint expressions with the corresponding alias
*/
protected def getAliasedConstraints(projectList: Seq[NamedExpression]): Set[Expression] = {
protected def getAllValidConstraints(projectList: Seq[NamedExpression]): Set[Expression] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getValidConstraints

var allConstraints = child.constraints.asInstanceOf[Set[Expression]]
projectList.foreach {
case a @ Alias(l: Literal, _) =>
Expand All @@ -170,7 +170,7 @@ abstract class UnaryNode extends LogicalPlan {
case _ => // Don't change.
}

allConstraints -- child.constraints
allConstraints
}

override protected def validConstraints: Set[Expression] = child.constraints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ case class Project(projectList: Seq[NamedExpression], child: LogicalPlan)
}

override def validConstraints: Set[Expression] =
child.constraints.union(getAliasedConstraints(projectList))
getAllValidConstraints(projectList)
}

/**
Expand Down Expand Up @@ -595,7 +595,7 @@ case class Aggregate(

override def validConstraints: Set[Expression] = {
val nonAgg = aggregateExpressions.filter(_.find(_.isInstanceOf[AggregateExpression]).isEmpty)
child.constraints.union(getAliasedConstraints(nonAgg))
getAllValidConstraints(nonAgg)
}
}

Expand Down