Repository navigation
Conversation
9349c50 to
18e48b4
Compare
comphead
left a comment
There was a problem hiding this comment.
The diagnosis holds. Spark's PlanAdaptiveDynamicPruningFilters only looks for a Spark BroadcastHashJoinExec in rootPlan (same code at v3.5.8, v4.0.1 and v4.1.1), and the outer transformUp never reaches a scan bridged at its own visit because CometScanWrapper is a leaf. Rewriting inside originalPlan is idempotent for nodes already rewritten, and the resulting CometSubqueryAdaptiveBroadcastExec on a plain Spark scan goes through the existing convertNonCometNodeDPP path. Without the fix, both tests fail at the CometSubqueryBroadcastExec count. The 10 removed lines are a comment only. The PR tier runs CometExecSuite on Spark 4.1 only, so run-all-spark-profiles would show whether the new plan-shape assertions also hold on 3.5, 4.0 and 4.2 (I did not run them). The CI (fork) failure was a Build Comet step in the first attempt of the Iceberg 1.11 job, and the rerun passed, so it is not tied to the diff.
| test("AQE DPP: V2 BatchScan bridged by CometSparkToColumnarExec keeps DPP") { | ||
| import testImplicits._ | ||
| withSQLConf( | ||
| "spark.sql.catalog.testcat" -> classOf[InMemoryTableCatalog].getName, | ||
| "spark.sql.defaultCatalog" -> "testcat", | ||
| SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true", |
There was a problem hiding this comment.
The fix also rewrites a non-AQE SubqueryBroadcastExec in a bridged BatchScanExec's runtimeFilters, but only the V1 test checks the non-AQE broadcast reuse. Looping over aqe <- Seq(true, false) here, with the same CometSubqueryBroadcastExec and ReusedExchangeExec checks as the V1 test, would cover V2 too. If the test name drops AQE, the cross-reference in the comment of AQE DPP: V2 BatchScan broadcast query stage creation order (SPARK-34637) needs the new name.
There was a problem hiding this comment.
Done in 91a215c: the V2 test now runs with AQE on and off, with the same non-AQE checks as the V1 test, and is renamed DPP: V2 BatchScan bridged by CometSparkToColumnarExec keeps DPP (the SPARK-34637 comment points to the new name). Both bridged tests also pass locally on the Spark 3.5, 4.0 and 4.2 profiles.
|
Thank you @comphead for reviewing the PR! The comment is addressed. |
91a215c to
d4560d9
Compare
A scan Comet bridges into Arrow sits in CometScanWrapper.originalPlan, which is not a child, so the SubqueryAdaptiveBroadcastExec in its partition filters was never wrapped. Spark's PlanAdaptiveDynamicPruningFilters then replaced the pruning with true and the scan read every partition. Rewrite DPP subqueries inside the wrapper's originalPlan too.
Run the bridged V1 scan test with AQE off as well, where the rewrite lets the DPP subquery reuse the join's Comet broadcast, and add a V2 BatchScan form of it (apache#4145). Update the SPARK-34637 V2 test comment that still described apache#4145 as open, and say in the helper's doc that the pruning is dropped only when the join goes native.
d4560d9 to
32831db
Compare
Which issue does this PR close?
Closes #4145.
Rationale for this change
When Comet bridges a scan into Arrow, the scan ends up in
CometScanWrapper.originalPlan, which is not a child.convertSubqueryBroadcaststherefore never sees the DPP subquery in its partition or runtime filters. Under AQE, when the join goes native, Spark'sPlanAdaptiveDynamicPruningFiltersthen replaces the pruning withtrue, and the scan reads every partition. Without AQE, the subquery keeps Spark'sSubqueryBroadcastExec, which still prunes but cannot reuse the join's Comet broadcast. This applies to V1 file scans as well as the V2 case in the issue.We hit it running TPC-DS 1TB on Hudi copy-on-write tables (S3, 10 executors of 16 cores, Spark 3.5). Comet bridges those scans because Hudi's file format is not Spark's Parquet format, so every fact scan read all 1,823 partitions. With the fix, Comet-mode scans prune like Spark's (the median
catalog_salesscan reads 364). Before the fix, Comet mode was 1.57x slower than Spark over the 88 queries both completed. After it, the 103-query run took 1151 s against Spark's 1520 s. q25, q72 and q77 were 2.3x to 9x slower than Spark, and now take 24.9 s in total against Spark's 28.8 s.What changes are included in this PR?
CometExecRule.transformalso rewrites DPP subqueries inside aCometScanWrapper'soriginalPlan, and it keeps the wrapper's tags. The rewrite is limited to the wrapper rather than moved ahead ofconvertNodefor every node, as #4145 suggests, so the other scan paths keep their current DPP handling. AtransformAllExpressionspass would not reachoriginalPlan, since it is not a child.How are these changes tested?
Two new
CometExecSuitetests:DPP: scan bridged by CometSparkToColumnarExec keeps DPPturns native scans off and Parquet conversion on, so the partitioned fact scan is bridged under a Comet broadcast hash join. With AQE on and off, it checks for oneCometSubqueryBroadcastExecand that the scan reads 1 of 10 partitions. Without AQE, it also checks that the join's broadcast is reused.DPP: V2 BatchScan bridged by CometSparkToColumnarExec keeps DPPdoes the same, with AQE on and off, for anInMemoryTableCatalogtable bridged throughspark.comet.sparkToColumnar, and checks that the scan returns 10 of the 100 fact rows.Without the fix, every case finds no
CometSubqueryBroadcastExec. On the default Spark 4.1 profile, all 57 tests pass in theDPPtests ofCometExecSuitetogether withCometBroadcastBuildSideSuite. The two new tests also pass locally on the Spark 3.5, 4.0 and 4.2 profiles.