Minor: remove confusing update_plan_from_children call from EnforceSorting#14650
Minor: remove confusing update_plan_from_children call from EnforceSorting#14650xudong963 merged 3 commits intoapache:mainfrom
update_plan_from_children call from EnforceSorting#14650Conversation
|
This will be the first PR that I'm improving the |
alamb
left a comment
There was a problem hiding this comment.
Thank you for starting to work on this code @xudong963
BTW I believe @wiedld is also plans to work to make this code better, see
Maybe you can work together to improve things
Happy to work together @xudong963 . Right now I'm working on:
I can make sure to add you as a reviewers on those. Please lmk if/how you want to coordinate. |
|
Also, it looks like the failing CI tests are related to the sort enforcement. Such as not removing unnecessary sorts in some of the children. |
The problem is that the code still depends on the I did more updates:
|
Sure, please add me. |
update_plan_from_children callupdate_plan_from_children call
update_plan_from_children callupdate_plan_from_children call from EnforceSorting
|
@wiedld can you please review this PR? |
There was a problem hiding this comment.
LGTM
I also made a draft PR with added docs, which references exactly why this PR is ok. I'll update conflicts & merge that in after this PR.
Note that we could have also change the meaning of the function to update_ctx_and_sync_children. Either way works.
alamb
left a comment
There was a problem hiding this comment.
Thank you @xudong963 and @wiedld -- it is really neat to see some others start working on this code. I expect it will get even better than it already is!
|
|
||
| /// Updates order-preservation data for all children of the given node. | ||
| pub fn update_children(opc: &mut OrderPreservationContext) { | ||
| pub fn update_children_data(opc: &mut OrderPreservationContext) { |
There was a problem hiding this comment.
I found the methods names hard to follow -- for example update_children_data actually has a OrderPreservationContext 🤔
There was a problem hiding this comment.
yes, I changed to update_order_preservation_ctx_children_data, longer but clearer
| /// A node object beneficial for writing optimizer rules, encapsulating an [`ExecutionPlan`] node with a payload. | ||
| /// Since there are two ways to access child plans—directly from the plan and through child nodes—it's recommended | ||
| /// to perform mutable operations via [`Self::update_plan_from_children`]. | ||
| /// After update `children`, please do the sync updating for `plan`'s children. |
There was a problem hiding this comment.
I wonder if we could find some way to avoid having to remember to do this 🤔
If we have to remember to call a function it seems likely either our future selves or others will forget to do so
There was a problem hiding this comment.
Maybe one way would be to make these fields not pub and then control access
so like add a method so the only way to update children woudl be
impl PlanContext {
fn update_children(&mut self, new_children: Vec<Self>) -> {
self.children = new_children;
self.update_child_data()
}🤔
To be clear I am talking about some future PR
There was a problem hiding this comment.
Yes, I've tried this way to make the operation "atomic", but I found it hard to change, most places acquire mut self for PlanContext.
I have another way to avoid the mind burden. Currrently, we have two parallel tree structures:
- The ExecutionPlan tree (through plan field and its children)
- The PlanContext tree (through children field)
I'm trying to make them single.
|
FYI @ozankabak and @berkaysynnada |
|
I plan to merge the PR, and then @wiedld can continue to his PR.
|
Which issue does this PR close?
Rationale for this change
update_sort_ctx_childrenonly updates the data field of the context nodes, which tracks whether nodes are connected to aSortExec.update_plan_from_children()is about updating the actual execution plan structure.The data field updates in
update_sort_ctx_childrendon't actually require any changes to the underlying execution plan.Therefore, the call to
update_plan_from_children()inupdate_sort_ctx_childrenappears unnecessary.So remove it to avoid confusion.
What changes are included in this PR?
remove unnecessary
update_plan_from_childrencallAre these changes tested?
Covered by existing tests
Are there any user-facing changes?