Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
fix test failure
  • Loading branch information
gengliangwang committed Jun 10, 2020
commit 3497b3c63848236274050a78b6d7bf19b314772d
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ object PushCNFPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelpe
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ object SQLConf {
.intConf
.checkValue(_ >= 0,
"The depth of the maximum rewriting conjunction normal form must be positive.")
.createWithDefault(10)
.createWithDefault(20)

val ESCAPED_STRING_LITERALS = buildConf("spark.sql.parser.escapedStringLiterals")
.internal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FilterPushdownSuite extends PlanTest {
object Optimize extends RuleExecutor[LogicalPlan] {

override protected val blacklistedOnceBatches: Set[String] =
Set("Push predicate through join by CNF")
Set("Push CNF predicate through join")

val batches =
Batch("Subqueries", Once,
Expand All @@ -45,7 +45,7 @@ class FilterPushdownSuite extends PlanTest {
BooleanSimplification,
PushPredicateThroughJoin,
CollapseProject) ::
Batch("Push predicate through join by CNF", Once,
Batch("Push CNF predicate through join", Once,
PushCNFPredicateThroughJoin) :: Nil
}

Expand Down Expand Up @@ -1340,26 +1340,6 @@ class FilterPushdownSuite extends PlanTest {
comparePlans(optimized, correctAnswer)
}

test("inner join: rewrite to conjunctive normal form avoid generating too many predicates") {
val x = testRelation.subquery('x)
val y = testRelation.subquery('y)

val originalQuery = {
x.join(y, condition = Some(("x.b".attr === "y.b".attr)
&& ((("x.a".attr > 3) && ("x.a".attr < 13) && ("y.c".attr <= 5))
|| (("y.a".attr > 2) && ("y.c".attr < 1)))))
}

val optimized = Optimize.execute(originalQuery.analyze)
val left = testRelation.subquery('x)
val right = testRelation.where('c <= 5 || ('a > 2 && 'c < 1)).subquery('y)
val correctAnswer = left.join(right, condition = Some("x.b".attr === "y.b".attr
&& ((("x.a".attr > 3) && ("x.a".attr < 13) && ("y.c".attr <= 5))
|| (("y.a".attr > 2) && ("y.c".attr < 1))))).analyze

comparePlans(optimized, correctAnswer)
}

test(s"Disable rewrite to CNF by setting ${SQLConf.MAX_CNF_NODE_COUNT.key}=0") {
val x = testRelation.subquery('x)
val y = testRelation.subquery('y)
Expand All @@ -1370,14 +1350,14 @@ class FilterPushdownSuite extends PlanTest {
|| (("y.a".attr > 2) && ("y.c".attr < 1)))))
}

Seq(0, 10).foreach { depth =>
withSQLConf(SQLConf.MAX_CNF_NODE_COUNT.key -> depth.toString) {
Seq(0, 10).foreach { count =>
withSQLConf(SQLConf.MAX_CNF_NODE_COUNT.key -> count.toString) {
val optimized = Optimize.execute(originalQuery.analyze)
val (left, right) = if (depth == 0) {
val (left, right) = if (count == 0) {
(testRelation.subquery('x), testRelation.subquery('y))
} else {
(testRelation.subquery('x),
testRelation.where('c <= 5 || ('a > 2 && 'c < 1)).subquery('y))
testRelation.where(('c <= 5 || 'c < 1) && ('c <=5 || 'a > 2)).subquery('y))
Copy link
Member Author

Choose a reason for hiding this comment

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

@wangyum To make it simple, this PR didn't convert the pushed down predicate to a shorter form.
We can have a follow-up PR if you like that feature.

}
val correctAnswer = left.join(right, condition = Some("x.b".attr === "y.b".attr
&& ((("x.a".attr > 3) && ("x.a".attr < 13) && ("y.c".attr <= 5))
Expand Down