Skip to content

Commit

Permalink
fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
gengliangwang committed Jun 5, 2020
1 parent 3c1423e commit 729be0f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
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 @@ -555,7 +555,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))
}
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

0 comments on commit 729be0f

Please sign in to comment.