Skip to content

fix(interactive): Support Multiple Matches in IR Core #3134

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

Merged
merged 18 commits into from
Aug 28, 2023

Conversation

BingqingLyu
Copy link
Collaborator

@BingqingLyu BingqingLyu commented Aug 22, 2023

What do these changes do?

As titled, support Multiple Matches in IR Core

  1. From now, the logical plan will contain contain a dummy RootScan after initialization by default. This dummy RootScan may be later used to support multiple scan.
  2. When a plan of a pattern matching is append to a node, if the plan is naive plan, it will directly append to the assigned node. Otherwise, it the plan is extend plan, then it must have its own scan operator, so it have to be append to the dummy RootScan
  3. When a sink operator is append to the logical plan, it suggests that the logical plan building is finished. Therefore, it will call clean_redundant_nodes method to clean useless nodes. There are two kinds of reduandant nodes: Scan node with no child and dummy RootScan with zero or only single child.

Related issue number

Fixes #3052 #3062

BingqingLyu and others added 9 commits July 28, 2023 11:13
Committed-by: bingqing.lbq from Dev container
Committed-by: bingqing.lbq from Dev container
1. Fix the bug of multiple pattern matching
2. Add more test cases for pattern matching
1. Edit testcases
2. Fix some bugs
3. Now the new multiple match implementation with dummy source can pass all the tests in the rust side
1. Update clean redundant methods. Now it will firstly remove all the redundant scan nodes, and then check the redundant dummy root node
2. It will ensure remove a redundant dummy root nodes which followed by another several of redundant scan nodes
@longbinlai longbinlai changed the title fix(interactive) Support Multiple Matches in IR Core fix(interactive): Support Multiple Matches in IR Core Aug 22, 2023
.unwrap_or(true)
}
_ => false,
impl pb::LogicalPlan {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -155,7 +168,7 @@ impl TryFrom<pb::LogicalPlan> for LogicalPlan {
return Err(ParsePbError::EmptyFieldError("Node::opr".to_string()));
}
}

plan.clean_redundant_nodes();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems would occur a duplicated clean_redundant_nodes() since it is also called in append_operator_as_node()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, and edit a testcase

let new_curr_node_rst = match opr.opr.as_ref().unwrap() {
Opr::Pattern(pattern) => {

let new_curr_node_rst = match opr.opr.as_ref() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can directly unwrap() since it is already checked.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to avoid unwrap in official code

false
}
} else {
false
Copy link
Collaborator Author

@BingqingLyu BingqingLyu Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if store_meta is not provided, params.tables.is_empty() also indicates all_labels()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

BingqingLyu and others added 5 commits August 22, 2023 11:33
1. remove `append_root` method

2. avoid repeated `clean_redundant_nodes()` use in try_from pb::LogicalPlan to LogicalPlan

3. Change the logic of `is_all_parameters()`. Now, as well as the params.tables.is_empty(), it is all parameters, no matter whether the store meta is provided or not

4. Remove an error testcase about multiple matches because it contains nested branch, which will be supoorted in the future version
1. In TryFrom pb::LogicalPlan to LogicalPlan, use pb.roots to suggests the root instead of id=0
2. Add comment about redirecting the parents of pb.roots to the dummy root of the LogicalPlan
@BingqingLyu BingqingLyu marked this pull request as draft August 22, 2023 10:08
@codecov-commenter
Copy link

codecov-commenter commented Aug 22, 2023

Codecov Report

Merging #3134 (180e6c7) into main (88c5180) will not change coverage.
Report is 1 commits behind head on main.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3134   +/-   ##
=======================================
  Coverage   42.64%   42.64%           
=======================================
  Files         100      100           
  Lines       10817    10817           
=======================================
  Hits         4613     4613           
  Misses       6204     6204           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f701fb8...180e6c7. Read the comment docs.

@BingqingLyu BingqingLyu marked this pull request as ready for review August 24, 2023 04:15
}
}

fn is_node_dummy(node: &Node) -> bool {
Copy link
Collaborator

@longbinlai longbinlai Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not implement as a member function of Node? Similar for is_node_scan. Furthermore, dummy not a good name for the function, call it root

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -469,6 +469,9 @@ message SinkVineyard {
schema.Schema graph_schema = 2;
}

// A dummy node to delegate a source opr for multiple scan cases.
message RootScan {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not like RootScan, Simply call it Root.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@longbinlai longbinlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BingqingLyu BingqingLyu merged commit f71a08d into alibaba:main Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Incorrect Logical Plan Generated for Join of Multiple Matches in IR Core
5 participants