fuwhu commented on a change in pull request #27232: 
[SPARK-30525][SQL]HiveTableScanExec do not need to prune partitions again after 
pushing down to hive metastore
URL: https://github.com/apache/spark/pull/27232#discussion_r368836983
 
 

 ##########
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveTableScanExec.scala
 ##########
 @@ -162,22 +162,41 @@ case class HiveTableScanExec(
     }
   }
 
-  // exposed for tests
-  @transient lazy val rawPartitions = {
-    val prunedPartitions =
-      if (sparkSession.sessionState.conf.metastorePartitionPruning &&
-          partitionPruningPred.size > 0) {
-        // Retrieve the original attributes based on expression ID so that 
capitalization matches.
-        val normalizedFilters = partitionPruningPred.map(_.transform {
-          case a: AttributeReference => originalAttributes(a)
-        })
-        sparkSession.sessionState.catalog.listPartitionsByFilter(
-          relation.tableMeta.identifier,
-          normalizedFilters)
-      } else {
+  @transient lazy val partitions: Seq[HivePartition] = {
+    if (sparkSession.sessionState.conf.metastorePartitionPruning &&
+      partitionPruningPred.nonEmpty) {
+      val normalizedFilters = partitionPruningPred.map(_.transform {
+        case a: AttributeReference => originalAttributes(a)
+      })
+      sparkSession.sessionState.catalog
+        .listPartitionsByFilter(relation.tableMeta.identifier, 
normalizedFilters)
+        .map(HiveClientImpl.toHivePartition(_, hiveQlTable))
+    } else {
+      val hivePartitions =
         
sparkSession.sessionState.catalog.listPartitions(relation.tableMeta.identifier)
+          .map(HiveClientImpl.toHivePartition(_, hiveQlTable))
+      if (partitionPruningPred.nonEmpty) {
+        prunePartitions(hivePartitions)
+      } else {
+        hivePartitions
       }
-    prunedPartitions.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
+    }
+  }
+
+  // Only for tests
+  @transient lazy val prunedPartitionsViaHiveMetastore: Seq[HivePartition] = {
 
 Review comment:
   The test is to verify the SQLConf HIVE_METASTORE_PARTITION_PRUNING, but the 
partitions method will return same result no matter 
HIVE_METASTORE_PARTITION_PRUNING is true or false.
   
   what about just remove the test case "Verify SQLConf 
HIVE_METASTORE_PARTITION_PRUNING" in HiveTableScanSuite?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to