-
Couldn't load subscription status.
- Fork 1.7k
Test and fix for issue #16998: SortExec shares DynamicFilterPhysicalExpr across multiple executions #17016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sicalExpr across multiple executions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @robertream , I enabled the CI process, will have a look later. /cc @adriangb
|
As you can see the current behavior was intentional and necessary for this functionality. IMO we should add a |
|
I was vibe coding this one as an experiment, so if this isn’t the right
fix, feel free to throw it away, I'm only out tokens, not labor/ :)
…On Fri, Aug 1, 2025 at 9:32 PM Adrian Garcia Badaracco < ***@***.***> wrote:
*adriangb* left a comment (apache/datafusion#17016)
<#17016 (comment)>
As you can see the current behavior was intentional and necessary for this
functionality. IMO we should add a .cloned() or with_new_state() method
to ExecutionPlan that defaults to with_new_children() and we call that
from places that don't want to preserve state.
—
Reply to this email directly, view it on GitHub
<#17016 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABFTGTNXNGNAJP47GELTKD3LQ5N5AVCNFSM6AAAAACC6EQJXSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCNBWGIYDKNJSGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
I am unfortunately AFK until Monday at which point I'll have a pileup of work stuff. So Monday evening or Tuesday I'll try something. My suggestion would be a new method that explicitly copies an ExecutionPlan resetting any state. |
Fixes apache#16998. Closes apache#17016.
|
@robertream I don't think I can push to your branch so I opened #17028 with my change / suggestions. Could you take a look? We should either incorporate feedback here or proceed with my PR. Either way I'll give you attribution in the commits there. |
Go with your PR, mine was part of an experiment |
Summary
Fixes #16998: SortExec shares DynamicFilterPhysicalExpr across multiple executions
This PR addresses an issue where
SortExecwas sharing the sameDynamicFilterPhysicalExpracross multiple invocations ofwith_new_children(e.g., fromreset_plan_states), causing recursive queries to fail.Changes
SortExec::with_new_children: Now properly clones theDynamicFilterPhysicalExprinstead of sharing the same instance across multiple executionstest_sort_exec_filter_cloning_issue_16998that reproduces the issue and verifies the fixProblem Description
The issue occurred when recursive queries would repeatedly execute the same
SortExecplan. The sharedDynamicFilterPhysicalExprwould maintain state across executions, leading to incorrect results. For example:This query would return only 2 rows instead of the expected 5 rows.
Solution
The fix ensures each
SortExecinstance gets its own copy of the dynamic filter by:DynamicFilterPhysicalExprinstance with the same children expressionsTest Verification
test_sort_exec_filter_cloning_issue_16998that specifically tests the recursive query scenario🤖 Generated with Claude Code