You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ulysses-you (via GitHub)" <gi...@apache.org> on 2023/08/02 10:18:55 UTC

[GitHub] [spark] ulysses-you commented on a diff in pull request #41088: [SPARK-43402][SQL] FileSourceScanExec supports push down data filter with scalar subquery

ulysses-you commented on code in PR #41088:
URL: https://github.com/apache/spark/pull/41088#discussion_r1281706092


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala:
##########
@@ -383,6 +383,24 @@ trait FileSourceScanLike extends DataSourceScanExec {
     }).flatMap(DataSourceStrategy.translateFilter(_, supportNestedPredicatePushdown))
   }
 
+  @transient
+  protected lazy val pushedDownFilters: Seq[Filter] = translatePushedDownFilters(dataFilters)
+
+  @transient
+  protected lazy val dynamicallyPushedDownFilters: Seq[Filter] = {
+    if (dataFilters.exists(_.exists(_.isInstanceOf[execution.ScalarSubquery]))) {
+      // Replace scalar subquery to literal so that `DataSourceStrategy.translateFilter` can
+      // support translate it. The subquery must has been materialized since SparkPlan always
+      // execute subquery first.
+      val normalized = dataFilters.map(_.transform {

Review Comment:
   Seems `selectedPartitions` does not accept subquery expression, it filter out the dpp filter first.
   
   https://github.com/apache/spark/blob/e326b9b6565b1e2b697d41714060e2ff9e424514/sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala#L252-L257
   
   Then in `dynamicallySelectedPartitions`,  normalized the partition filter.
   
   https://github.com/apache/spark/blob/e326b9b6565b1e2b697d41714060e2ff9e424514/sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala#L268-L281



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org