From 729be0fb7c4939261afd9fb7ea68876d12933532 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Fri, 5 Jun 2020 00:55:59 -0700 Subject: [PATCH] fix test failure --- .../PushCNFPredicateThroughJoin.scala | 2 +- .../apache/spark/sql/internal/SQLConf.scala | 2 +- .../optimizer/FilterPushdownSuite.scala | 32 ++++--------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushCNFPredicateThroughJoin.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushCNFPredicateThroughJoin.scala index bd19d63ed9d1c..c0be070b9dbab 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushCNFPredicateThroughJoin.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushCNFPredicateThroughJoin.scala @@ -136,4 +136,4 @@ object PushCNFPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelpe } } } -} \ No newline at end of file +} diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala index d3c16133cf6fb..2c92843427713 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala @@ -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() diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala index 64c093b5ed6c5..1220278bad37c 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala @@ -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, @@ -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 } @@ -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) @@ -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))