-
Notifications
You must be signed in to change notification settings - Fork 222
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
feat: prevent wildcard aliasing #1096
Conversation
f42ff80
to
12bc32c
Compare
12bc32c
to
2b7d5c7
Compare
(I've seen this but I think @aljazerzen by far the better reviewer — IIUC he is traveling but is back quite soon) |
I agree, this is also similar to the proposal for now name resolution would work; now outlined in the |
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'll do a refactor and add more info on how to do this.
self.next_col_name_id += 1; | ||
match &def.expr.kind { | ||
ExprKind::ExternRef { variable, .. } if variable == "*" => { | ||
def.name = Some("*".into()); |
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.
This is clever but a bit hacky. Passing a "*"
does indeed prevent alias to be emitted, because it uses rule that SQL assumes alias from ident names only, so we omit explicit alias.
If we don't want to rely on this rule, I have to do a little refactor.
Hey, my little refactor got out of hand :D I ended up doing exactly what you suggested @MarinPostma . I wanted to give more directions on how to do it, but it ended up being very connected to many different parts of the compiler, which is not ideal for onboarding. This is the commit that partially does this: And this is the other part: |
@MarinPostma thanks for the effort — we're v happy to have you as a regular contributor, and there's much more to do! |
This pr prevents wildcard aliasing. This is done in the
ensure_column_name
method, by checking if the considered column is a wildcard, in which case, we set its name to"*"
.This is pretty hacky, by also works with ctes.
Maybe a better approach would be to change
ColumnDef
to something like:By my knowledge of the project is not yet good enough to judge all the implications.
I haven't re-enabled any tests yet, it makes more sense to do that once #1094 is merged.