-
Notifications
You must be signed in to change notification settings - Fork 526
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
feat(optimizer): refactor multijoin(part 1) #3351
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3351 +/- ##
=======================================
Coverage 73.59% 73.59%
=======================================
Files 766 765 -1
Lines 104914 104937 +23
=======================================
+ Hits 77210 77231 +21
- Misses 27704 27706 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
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.
Rest LGTM
@@ -35,6 +38,18 @@ pub struct LogicalMultiJoin { | |||
pub base: PlanBase, | |||
inputs: Vec<PlanRef>, | |||
on: Condition, | |||
output_indices: Vec<usize>, | |||
// XXX(st1page): these fields will be used in prune_col and pk_derive soon. | |||
#[allow(unused)] |
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.
expect(dead_code)
ExprImpl::InputRef(input_ref) => Some(input_ref.index), | ||
_ => None, | ||
}) | ||
.collect::<Option<Vec<_>>>() |
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.
In what case will it return None? Shall we report error instead of returning None?
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.
Not all project node is a "projection" operation (all expressions are input_ref), and the None case is general and I will add some comments here.
can merge? |
Excuse me. I think MultiJoinRule transforms some node about join into multi-join node. Is this a correct understanding? |
I still do not get why the tpch plan is changed... but the plan is correct and e2e has passed so I will update the branch and if ci is ok, I will merge |
Yes, It is for join reorder in our system now. And later we will see if it can help in streaming optimization phase. |
IIRC mostly join order changes? |
All. and the join order does not go worse. It is strange but harmless. |
Thanks for answering me. I saw the comments in merge_multijoin.rs, so does MultiJoinRule reallly merges some nodes to one on logical plan tree? |
yes, it rewrite the plan tree. |
What's changed and what's your intention?
this refactor is for #3013. if the multi join will not only be a short-lived operator, we should implement more methods like prune_col pk_derive and clone_with_inputs to like it can be used in the heuristic optimizer.
LogicalMultiJoin::new
also calculate some mappings which might be used in other methods likeprune_col
andrewrite_for_stream
.LogicalMultiJoin::new
more expensive, change the merge multijoin method. implement a multijoin builder which travels the plan tree with Post-Order and build the multijointhis PR does not change the join-reorder algorithm but some join order in tpch plan is changed, I am still investing what happened.
Checklist
./risedev check
(or alias,./risedev c
)Refer to a related PR or issue link (optional)