Skip to content
Closed
Changes from 1 commit
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
Next Next commit
add constranits
  • Loading branch information
huleilei committed Feb 25, 2018
commit 705ed462bb307871e65199ce02576f12d60d2176
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,26 @@ trait QueryPlanConstraints { self: LogicalPlan =>
*/
lazy val constraints: ExpressionSet = {
if (conf.constraintPropagationEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

now we don't need this if.

var relevantOutPutSet: AttributeSet = outputSet
constraints.foreach {
case eq @ EqualTo(l: Attribute, r: Attribute) =>
Copy link
Member

Choose a reason for hiding this comment

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

eq isn't used

if (l.references.subsetOf(relevantOutPutSet)
Copy link
Member

Choose a reason for hiding this comment

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

You can avoid computing each subsetOf twice here.

&& !r.references.subsetOf(relevantOutPutSet)) {
relevantOutPutSet = relevantOutPutSet.++(r.references)
Copy link
Member

Choose a reason for hiding this comment

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

Use ++ syntax, rather than write it as a method invocation.

}
if (r.references.subsetOf(relevantOutPutSet)
&& !l.references.subsetOf(relevantOutPutSet)) {
relevantOutPutSet = relevantOutPutSet.++(l.references)
}
case _ => // No inference
}

ExpressionSet(
validConstraints
.union(inferAdditionalConstraints(validConstraints))
.union(constructIsNotNullConstraints(validConstraints))
.filter { c =>
c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic
c.references.nonEmpty && c.references.subsetOf(relevantOutPutSet) && c.deterministic
}
)
} else {
Expand Down