peter-toth commented on code in PR #52628:
URL: https://github.com/apache/spark/pull/52628#discussion_r2435539594


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/BatchScanExec.scala:
##########
@@ -67,59 +71,115 @@ case class BatchScanExec(
       case _ => None
     }
 
-    if (dataSourceFilters.nonEmpty) {
-      val originalPartitioning = outputPartitioning
+    val predicateFiltered = if (dataSourceFilters.nonEmpty) {
+      predicateFilter(dataSourceFilters)
+    } else {
+      partitions
+    }
 
-      // the cast is safe as runtime filters are only assigned if the scan can 
be filtered
-      val filterableScan = scan.asInstanceOf[SupportsRuntimeV2Filtering]
-      filterableScan.filter(dataSourceFilters.toArray)
+    // Apply additional filtering based on partition keys if available
+    if (allFilters.nonEmpty) {

Review Comment:
   Seems like when you create `BatchScanExec` you pass in `allFilters`, which 
contains both `runtimeFilters` and `postScanFilters`, but we already have 
`runtimeFilters`.
   Would it make sense to just pass in `postScanFilters` and compute 
`allFilters` here?
   
   Can `allFilters` be computed as `runtimeFilters` that can't be translated to 
V2 + `postScanFilters`? Or we can't be sure that `filterableScan.filter()` 
applies all translated `runtimeFilters`?



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

To unsubscribe, e-mail: [email protected]

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