gengliangwang commented on a change in pull request #27112: [SPARK-30428][SQL] 
File source V2: support partition pruning
URL: https://github.com/apache/spark/pull/27112#discussion_r364389458
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PruneFileSourcePartitions.scala
 ##########
 @@ -39,31 +72,35 @@ private[sql] object PruneFileSourcePartitions extends 
Rule[LogicalPlan] {
             _,
             _))
         if filters.nonEmpty && fsRelation.partitionSchemaOption.isDefined =>
-      val normalizedFilters = DataSourceStrategy.normalizeExprs(
-        filters.filterNot(SubqueryExpression.hasSubquery), 
logicalRelation.output)
-
-      val sparkSession = fsRelation.sparkSession
-      val partitionColumns =
-        logicalRelation.resolve(
-          partitionSchema, sparkSession.sessionState.analyzer.resolver)
-      val partitionSet = AttributeSet(partitionColumns)
-      val partitionKeyFilters = ExpressionSet(normalizedFilters.filter { f =>
-        f.references.subsetOf(partitionSet)
-      })
-
+      val partitionKeyFilters = getPartitionKeyFilters(
+        fsRelation.sparkSession, logicalRelation, partitionSchema, filters, 
logicalRelation.output)
       if (partitionKeyFilters.nonEmpty) {
         val prunedFileIndex = 
catalogFileIndex.filterPartitions(partitionKeyFilters.toSeq)
         val prunedFsRelation =
-          fsRelation.copy(location = prunedFileIndex)(sparkSession)
+          fsRelation.copy(location = prunedFileIndex)(fsRelation.sparkSession)
 
 Review comment:
   @guykhazma Thanks for the suggestion.
   However, the `PartitioningAwareFileIndex` doesn't use the data filters for 
listing files. Could you provide an example that the data filters will be 
useful here?
   Also, the data filters are supposed to be pushed down in `FileScanBuiler` 
(e.g ORC/Parquet)
   

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