Skip to content
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

Enhance derived unfold rule to handle expressions other than column ref #67

Open
jiangzhe opened this issue Feb 26, 2022 · 0 comments
Open
Labels
feature New feature or request

Comments

@jiangzhe
Copy link
Owner

jiangzhe commented Feb 26, 2022

This rule does not support unfold derived table as inner side of outer join if the output contains expressions other than columns.
The reason is that outer join may change the output of inner side, and it's not safe to unfold and replace expressions in parent tree with derived table's output directly.
MySQL's uses ItemRef to implements its "derived merge" logic. Additional care will be taken in join operator to make sure non-matched rows only result in NULL.
We can take this approach, to add a InnerRef variant in Expr, then logical optimization is free to unfold outer join's children.
When bottom up traversing the parent tree, we do normal replace.
Once outer join encountered and the unfold is from the inner side, we can wrap original expressions(other than single column) with InnerRef and store them into join operator. Join operator will evaluate them with care of outer join semantics.

@jiangzhe jiangzhe added the feature New feature or request label Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant