LuciferYang commented on code in PR #55579:
URL: https://github.com/apache/spark/pull/55579#discussion_r3223459898


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala:
##########
@@ -186,6 +188,21 @@ trait FileScan extends Scan
     partitions.toArray
   }
 
+  /**
+   * SPARK-30628: produce InputPartitions taking additional runtime filters 
into account.
+   * Called by `BatchScanExec.filteredPartitions` with DPP and scalar-subquery 
filters that
+   * must apply on top of the scan's compile-time `partitionFilters`. Returns 
the same
+   * partitions as `planInputPartitions()` when `extraFilters` is empty.
+   */
+  def planInputPartitionsWithRuntimeFilters(
+      extraFilters: Seq[Expression]): Array[InputPartition] = {
+    if (extraFilters.isEmpty) {
+      planInputPartitions()
+    } else {
+      partitionsImpl(partitionFilters ++ extraFilters).toArray

Review Comment:
   Good catch — answers below, addressed in d544f201629:
   
   1. Existing third-party `FileScan` subclasses that override the `protected 
def partitions` keep working. The compile-time path (`planInputPartitions`) 
still calls `partitions`, so their override is honored. The new 
`planInputPartitionsWithRuntimeFilters` only diverges from that path when 
`extraFilters` is non-empty — when it's empty, the method delegates to 
`planInputPartitions()`. So existing sources see no behavior change; they 
simply won't benefit from the runtime-filter pruning unless they migrate to 
override `partitionsImpl`.
   2. Added Scaladoc on `partitions`, `partitionsImpl`, and 
`planInputPartitionsWithRuntimeFilters` documenting that subclasses should 
override `partitionsImpl` so the customization applies to both code paths.



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