Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/13585#discussion_r66714314
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/QueryPartitionSuite.scala ---
@@ -65,4 +69,95 @@ class QueryPartitionSuite extends QueryTest with
SQLTestUtils with TestHiveSingl
sql("DROP TABLE IF EXISTS createAndInsertTest")
}
}
+
+ test("partition pruning in disjunction") {
+ withSQLConf((SQLConf.HIVE_VERIFY_PARTITION_PATH.key, "true")) {
+ val testData = sparkContext.parallelize(
+ (1 to 10).map(i => TestData(i, i.toString))).toDF()
+ testData.registerTempTable("testData")
+
+ val testData2 = sparkContext.parallelize(
+ (11 to 20).map(i => TestData(i, i.toString))).toDF()
+ testData2.registerTempTable("testData2")
+
+ val testData3 = sparkContext.parallelize(
+ (21 to 30).map(i => TestData(i, i.toString))).toDF()
+ testData3.registerTempTable("testData3")
+
+ val testData4 = sparkContext.parallelize(
+ (31 to 40).map(i => TestData(i, i.toString))).toDF()
+ testData4.registerTempTable("testData4")
+
+ val tmpDir = Files.createTempDir()
+ // create the table for test
+ sql(s"CREATE TABLE table_with_partition(key int,value string) " +
+ s"PARTITIONED by (ds string, ds2 string) location
'${tmpDir.toURI.toString}' ")
+ sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='1',
ds2='d1') " +
+ "SELECT key,value FROM testData")
+ sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='2',
ds2='d1') " +
+ "SELECT key,value FROM testData2")
+ sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='3',
ds2='d3') " +
+ "SELECT key,value FROM testData3")
+ sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='4',
ds2='d4') " +
+ "SELECT key,value FROM testData4")
+
+ checkAnswer(sql("select key,value from table_with_partition"),
+ testData.collect ++ testData2.collect ++ testData3.collect ++
testData4.collect)
+
+ checkAnswer(
+ sql(
+ """select key,value from table_with_partition
+ | where (ds='4' and key=38) or (ds='3' and
key=22)""".stripMargin),
+ Row(38, "38") :: Row(22, "22") :: Nil)
+
+ checkAnswer(
+ sql(
+ """select key,value from table_with_partition
+ | where (key<40 and key>38) or (ds='3' and
key=22)""".stripMargin),
+ Row(39, "39") :: Row(22, "22") :: Nil)
+
+ sql("DROP TABLE table_with_partition")
+ sql("DROP TABLE createAndInsertTest")
--- End diff --
good catch. :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]