-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-3214] Add UnionToUnionRule for materialization matching. #1333
Conversation
feeb8a7
to
b8a6702
Compare
What if the inputs of union have different column aliases? The union's output column names are expected to be the same with its first child. |
List<MutableRel> queryInputs = query.getInputs(); | ||
List<MutableRel> targetInputs = target.getInputs(); | ||
if (queryInputs.size() == targetInputs.size()) { | ||
while (!queryInputs.isEmpty()) { |
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.
How about using for loop (i .. n) here? I don't think removing elements in query inputs is necessary. Other than that, looks good to me.
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.
hmm~ let me think. The process of removing elements might be useful/necessary.
Let's make an example. Say Query and MV are like below:
Query:
Union
+--ScanA
+--ScanA
+--ScanB
MV:
Union
+--ScanA
+--ScanB
+--ScanB
Obviously the matching should be failed, but if I implement like below:
if (queryInputs.size() == targetInputs.size()) {
for (MutableRel rel: queryInputs) {
if (targetInputs.indexOf(queryInputs.get(0)) == -1) {
return null;
}
}
}
return true;
The matching will succeeded, which is not correct. Though all input scans of query exist in MV, the counts are different.
THX again for review this :)
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.
No, this is what I mean:
if (queryInputs.size() == targetInputs.size()) {
for (MutableRel rel: queryInputs) {
int index = targetInputs.indexOf(rel);
if (index == -1) {
return null;
} else {
targetInputs.remove(index);
}
}
}
You don't need to remove twice. Does this make sense?
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.
Ah~ I got it~ Thanks ~ refine soon.
b8a6702
to
7187049
Compare
Thanks @hsyuan for review this ~ |
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.
+1
Thanks for approve ~ |
Below materialization matching fails now
This PR proposes to add a rule for Union matching