viirya commented on a change in pull request #23802: [SPARK-26893][SQL] Allow 
pushdown of partition pruning subquery filters to file source
URL: https://github.com/apache/spark/pull/23802#discussion_r257455412
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/SubquerySuite.scala
 ##########
 @@ -1281,6 +1283,24 @@ class SubquerySuite extends QueryTest with 
SharedSQLContext {
     }
   }
 
+  test("SPARK-26893: Allow pushdown of partition pruning subquery filters to 
file source") {
+    withTable("a", "b") {
+      spark.range(4).selectExpr("id", "id % 2 AS 
p").write.partitionBy("p").saveAsTable("a")
+      spark.range(2).write.saveAsTable("b")
+
+      val df = sql("SELECT * FROM a WHERE p <= (SELECT MIN(id) FROM b)")
+      checkAnswer(df, Seq(Row(0, 0), Row(2, 0)))
+      assert(df.queryExecution.executedPlan match {
+        case WholeStageCodegenExec(fs @ FileSourceScanExec(_, _, _, 
partitionFilters, _, _, _))
+          if partitionFilters.exists(ExecSubqueryExpression.hasSubquery) &&
+            fs.inputRDDs().forall(
+              _.asInstanceOf[FileScanRDD].filePartitions.forall(
+                _.files.forall(_.filePath.contains("p=0")))) => true
 
 Review comment:
   <del>This asserts partition `p=0` is read, but doesn't assert that other 
partitions are not read. Isn't it?</del>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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