cloud-fan commented on a change in pull request #29831:
URL: https://github.com/apache/spark/pull/29831#discussion_r504397253



##########
File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/PrunePartitionSuiteBase.scala
##########
@@ -46,30 +47,59 @@ abstract class PrunePartitionSuiteBase extends QueryTest 
with SQLTestUtils with
         }
 
         assertPrunedPartitions(
-          "SELECT * FROM t WHERE p = '1' OR (p = '2' AND i = 1)", 2)
+          "SELECT * FROM t WHERE p = '1' OR (p = '2' AND i = 1)", 2,
+          Set("`p`='1'", "`p`='2'"))
         assertPrunedPartitions(
-          "SELECT * FROM t WHERE (p = '1' AND i = 2) OR (i = 1 OR p = '2')", 4)
+          "SELECT * FROM t WHERE (p = '1' AND i = 2) OR (i = 1 OR p = '2')", 4,
+          Set())
         assertPrunedPartitions(
-          "SELECT * FROM t WHERE (p = '1' AND i = 2) OR (p = '3' AND i = 3 )", 
2)
+          "SELECT * FROM t WHERE (p = '1' AND i = 2) OR (p = '3' AND i = 3 )", 
2,
+          Set("`p`='1'", "`p`='3'"))
         assertPrunedPartitions(
-          "SELECT * FROM t WHERE (p = '1' AND i = 2) OR (p = '2' OR p = '3')", 
3)
+          "SELECT * FROM t WHERE (p = '1' AND i = 2) OR (p = '2' OR p = '3')", 
3,
+          Set("`p`='1'", "`p`='2'", "`p`='3'"))
         assertPrunedPartitions(
-          "SELECT * FROM t", 4)
+          "SELECT * FROM t", 4,
+          Set())
         assertPrunedPartitions(
-          "SELECT * FROM t WHERE p = '1' AND i = 2", 1)
+          "SELECT * FROM t WHERE p = '1' AND i = 2", 1,
+          Set("`p`='1'"))
         assertPrunedPartitions(
           """
             |SELECT i, COUNT(1) FROM (
             |SELECT * FROM t WHERE  p = '1' OR (p = '2' AND i = 1)
             |) tmp GROUP BY i
-          """.stripMargin, 2)
+          """.stripMargin, 2, Set("`p`='1'", "`p`='2'"))
       }
     }
   }
 
-  protected def assertPrunedPartitions(query: String, expected: Long): Unit = {
-    val plan = sql(query).queryExecution.sparkPlan
-    assert(getScanExecPartitionSize(plan) == expected)
+  private def collectEqualExp(
+      expression: Expression,
+      currentSet: Set[String]): Set[String] = expression match {
+    case e: EqualTo =>
+      currentSet + (e.left.sql + e.symbol + e.right.sql)
+        .replaceAll("spark_catalog.default.t.", "")
+    case _ =>
+      expression.children.foldLeft(currentSet)((s, exp) => 
collectEqualExp(exp, s))

Review comment:
       can we put `and`, `or` in the result? I think the test should check 
`and/or` as well, not just the leaf predicates.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to