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
Rewrite joins written with the USING construct #6660
Conversation
If a join has been expressed as: ``` FROM tblA JOIN tblB USING (col1,col2) ``` it will be rewritten to ``` FROM tblA JOIN tblB ON tblA.col1 = tblB.col1 AND tblA.col2 = tblB.col2 ``` This allows our planner to recognize these queries and plan them correctly. Signed-off-by: Andres Taylor <andres@planetscale.com>
Will this collapse the |
I vaguely remember that there was a specific corner case where this approach wouldn't work. I'll need to dig into some more info to find out why. |
Ok. I remember now. It becomes ambiguous in the case of multi-table joins (if we don't know the schema). We'll need to lookup the documentation. |
Signed-off-by: Andres Taylor <andres@planetscale.com>
The differences are all around which columns are available in the result set. Here are two examples that show differences that we would need to handle:
TL;DR; Changing the JOIN also changes the output, which I did not expect. This rewrite is not as easy as I first thought. Backing off for now. :( |
Signed-off-by: GuptaManan100 <manan@planetscale.com>
Signed-off-by: GuptaManan100 <manan@planetscale.com>
Signed-off-by: GuptaManan100 <manan@planetscale.com>
# join with USING construct | ||
"select user.id from user join user_extra using(id)" | ||
{ |
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.
add a test for non-vindex column in projection to see if that 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.
we're not touching this logic at all. all we are doing is rewriting USING to ON in the rewriter
Signed-off-by: GuptaManan100 <manan@planetscale.com>
Signed-off-by: GuptaManan100 <manan@planetscale.com>
Signed-off-by: GuptaManan100 <manan@planetscale.com>
Fixes #7119 |
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Very limited support for using Limitations:
Some frameworks seem to need at least this form (#7119), and so this PR seemed like an acceptable path forward in lieu of more substantial reworking of the join planning. |
If a join has been expressed as:
it will be rewritten to
This allows our planner to recognize these queries and plan them correctly.