CodingCat commented on a change in pull request #29831:
URL: https://github.com/apache/spark/pull/29831#discussion_r501432300



##########
File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala
##########
@@ -254,22 +254,28 @@ private[hive] trait HiveStrategies {
    * Retrieves data using a HiveTableScan.  Partition pruning predicates are 
also detected and
    * applied.
    */
-  object HiveTableScans extends Strategy {
+  object HiveTableScans extends Strategy with PredicateHelper {
     def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
-      case ScanOperation(projectList, predicates, relation: HiveTableRelation) 
=>
+      case ScanOperation(projectList, filters, relation: HiveTableRelation) =>
         // Filter out all predicates that only deal with partition keys, these 
are given to the
         // hive table scan operator to be used for partition pruning.
         val partitionKeyIds = AttributeSet(relation.partitionCols)
-        val (pruningPredicates, otherPredicates) = predicates.partition { 
predicate =>
-          !predicate.references.isEmpty &&
-          predicate.references.subsetOf(partitionKeyIds)
+        val normalized = DataSourceStrategy.normalizeExprs(
+          filters.filter(_.deterministic), relation.output)
+        val partitionKeyFilters = if (relation.partitionCols.isEmpty) {
+          ExpressionSet(Nil)
+        } else {
+          val predicates = ExpressionSet(normalized
+            .flatMap(extractPredicatesWithinOutputSet(_, partitionKeyIds)))
+          logInfo(s"Pruning partitions with: ${filters.mkString(",")}")
+          predicates
         }
 
         pruneFilterProject(
           projectList,
-          otherPredicates,
+          (ExpressionSet(filters) -- partitionKeyFilters).toSeq,

Review comment:
       @cloud-fan sorry, missed this, you're right, just changed




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