yihua opened a new pull request, #7761:
URL: https://github.com/apache/datafusion-comet/pull/7761

   ## 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. 
`convertSubqueryBroadcasts` therefore never sees the 
`SubqueryAdaptiveBroadcastExec` in its partition or runtime filters, so it is 
never wrapped. Spark's `PlanAdaptiveDynamicPruningFilters` then replaces the 
pruning with `true`, and the scan reads every partition. This applies to V1 
file scans as well as the V2 case in the issue. We hit it running TPC-DS on 
Hudi tables, where every fact scan read all partitions.
   
   ## What changes are included in this PR?
   
   `CometExecRule.transform` also rewrites DPP subqueries inside a 
`CometScanWrapper`'s `originalPlan`, and it keeps the wrapper's tags.
   
   ## How are these changes tested?
   
   A new `CometExecSuite` test, `AQE DPP: scan bridged by 
CometSparkToColumnarExec keeps DPP`. It turns native scans off and Parquet 
conversion on, so the partitioned fact scan is bridged by 
`CometSparkToColumnarExec` under a Comet broadcast hash join. It then checks 
for one `CometSubqueryBroadcastExec` and asserts that the scan reads 1 of 10 
partitions.
   
   The test fails without the fix: no `CometSubqueryBroadcastExec`, and every 
partition is read. With the fix, these suites pass on the default Spark 4.1 
profile:
   
   - the `AQE DPP` tests in `CometExecSuite`, including the new one (37);
   - the `AQE DPP` tests in `CometBroadcastBuildSideSuite` (3);
   - `CometExecRuleSuite` (126).
   
   The `CometExecSuite` `AQE DPP` tests also pass on `-Pspark-3.5`.
   


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