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 @@ -35,7 +35,8 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT
.union(inferAdditionalConstraints(constraints))
.union(constructIsNotNullConstraints(constraints))
.filter(constraint =>
constraint.references.nonEmpty && constraint.references.subsetOf(outputSet))
constraint.references.nonEmpty && constraint.references.subsetOf(outputSet) &&
constraint.deterministic)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,21 @@ class ConstraintPropagationSuite extends SparkFunSuite {
verifyConstraints(tr.analyze.constraints,
ExpressionSet(Seq(IsNotNull(resolveColumn(tr, "b")), IsNotNull(resolveColumn(tr, "c")))))
}

test("not infer non-deterministic constraints") {
val tr = LocalRelation('a.int, 'b.string, 'c.int)

verifyConstraints(tr
.where('a.attr === Rand(0))
.analyze.constraints,
ExpressionSet(Seq(IsNotNull(resolveColumn(tr, "a")))))

verifyConstraints(tr
.where('a.attr === InputFileName())
.where('a.attr =!= 'c.attr)
.analyze.constraints,
ExpressionSet(Seq(resolveColumn(tr, "a") =!= resolveColumn(tr, "c"),
IsNotNull(resolveColumn(tr, "a")),
IsNotNull(resolveColumn(tr, "c")))))
}
}