-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
leave aliases in projection #1930
Conversation
@@ -1124,7 +1124,22 @@ Select * from ( | |||
{ | |||
Query: `select y, (select 1 from uv where y = 1 and u = x) is_one from xy join uv on x = v order by y;`, | |||
ExpectedPlan: "Project\n" + | |||
" ├─ columns: [xy.y:1, is_one:4]\n" + | |||
" ├─ columns: [xy.y:1, Subquery\n" + |
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.
i'm kind of surprised this doesn't break sometimes. i intentionally separate subquery expressions from their inputs so that correlated subqueries get their inputs. i guess if we stack them deep enough the subqueries still get their inputs. either way this isn't ideal, we need lateral joins to avoid the duplicate exec and naming trade-offs
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.
Kind of skeptical of this one, but if it works it works. The duplication is kind of painful, but using lateral joins to fix subquery duplication/naming is within arms length now.
We convert
expression.Alias
intoexpression.GetField
with the name replaced in the top-level projection.When aliasing two different columns with the same name, we fail to properly distinguish them and end up rewriting the GetField indexes for both columns to be the same; this leads to incorrect results.
A simple fix appears to be simply allowing the top-level projection to remain as an
expression.Alias
.This fix does not work for prepared statements in the old name resolution path.
fix for: dolthub/dolt#6455