Kristofferjoha opened a new pull request, #26670:
URL: https://github.com/apache/datafusion/pull/26670

   ## Which issue does this PR close?
   
   Closes #26642.
   
   ## Rationale for this change
   
   TopK dynamic filters inside recursive CTEs stop updating the scan because 
`SortExec::reset_state()` creates a new filter on each iteration, while the 
scan still references the original one. This prevents pruning during recursive 
queries.
   
   ## What changes are included in this PR?
   
   - Reset the existing shared dynamic filter instead of replacing it.
   - Rebuild the TopK filter state using the existing 
`DynamicFilterPhysicalExpr`.
   - Add a recursive TopK regression test in `cte.slt`.
   
   Depends on #26056 for `DynamicFilterPhysicalExpr::reset()`. It hasn't been 
merged yet, but it has been approved, so I based this change on its 
implementation.
   
   ## What is the testing strategy for this PR?
   
   The new `cte.slt` case checks that the recursive query returns 1–4 and that 
the Parquet scan outputs 30 rows instead of 300, pruning 27 row groups across 
three iterations.
   
   ## Are there any user-facing changes?
   
   No.


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