cloud-fan commented on a change in pull request #30408:
URL: https://github.com/apache/spark/pull/30408#discussion_r528775772
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/client/HivePartitionFilteringSuite.scala
##########
@@ -297,6 +294,61 @@ class HivePartitionFilteringSuite(version: String)
day :: Nil)
}
+ test("getPartitionsByFilter: date type pruning by metastore") {
+ val table = CatalogTable(
+ identifier = TableIdentifier("test_date", Some("default")),
+ tableType = CatalogTableType.MANAGED,
+ schema = new StructType().add("value", "int").add("part", "date"),
+ partitionColumnNames = Seq("part"),
+ storage = storageFormat)
+ client.createTable(table, ignoreIfExists = false)
+
+ val partitions =
+ for {
+ date <- Seq("2019-01-01", "2019-01-02", "2019-01-03", "2019-01-04")
+ } yield CatalogTablePartition(Map(
+ "part" -> date
+ ), storageFormat)
+ assert(partitions.size == 4)
+
+ client.createPartitions("default", "test_date", partitions, ignoreIfExists
= false)
+
+ def testDataTypeFiltering(
+ filterExprs: Seq[Expression],
+ expectedPartitionCubes: Seq[Seq[Date]]): Unit = {
+ val filteredPartitions = client.getPartitionsByFilter(
+ client.getTable("default", "test_date"),
+ filterExprs,
+ SQLConf.get.sessionLocalTimeZone)
+
+ val expectedPartitions = expectedPartitionCubes.map {
+ expectedDt =>
+ for {
+ dt <- expectedDt
+ } yield Set(
+ "part" -> dt.toString
+ )
+ }.reduce(_ ++ _)
+
+ assert(filteredPartitions.map(_.spec.toSet).toSet ==
expectedPartitions.toSet)
+ }
+
+ testDataTypeFiltering(
+ Seq(AttributeReference("part", DateType)() ===
Date.valueOf("2019-01-01")),
Review comment:
can we create an `attr` method to get the `AttributeReference` from the
table? to follow other tests.
----------------------------------------------------------------
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]