-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Minor: remove confusing update_plan_from_children
call from EnforceSorting
#14650
Conversation
This will be the first PR that I'm improving the |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 @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!
@@ -45,7 +45,7 @@ use itertools::izip; | |||
pub type OrderPreservationContext = PlanContext<bool>; | |||
|
|||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the methods names hard to follow -- for example update_children_data
actually has a OrderPreservationContext
🤔
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.
yes, I changed to update_order_preservation_ctx_children_data
, longer but clearer
@@ -42,6 +42,8 @@ impl DynTreeNode for dyn ExecutionPlan { | |||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_children
only 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_children
don't actually require any changes to the underlying execution plan.Therefore, the call to
update_plan_from_children()
inupdate_sort_ctx_children
appears unnecessary.So remove it to avoid confusion.
What changes are included in this PR?
remove unnecessary
update_plan_from_children
callAre these changes tested?
Covered by existing tests
Are there any user-facing changes?