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

Alias resolution updates #1281

Merged
merged 29 commits into from
Sep 27, 2022
Merged

Alias resolution updates #1281

merged 29 commits into from
Sep 27, 2022

Conversation

fulghum
Copy link
Contributor

@fulghum fulghum commented Sep 23, 2022

This change moves our alias identification and column name qualification code closer to MySQL's behavior. The major changes are:

  • identify available alias, table, and column names on a per-scope level (instead of the previous "nestingLevel" that was based off of the node depth of the execution plan tree)
  • supply additional context to the qualifyExpression method so that the containing node can be used to switch on different alias visibility rules

There are still more nuanced edge cases in MySQL's alias behavior that we should continue working on matching (e.g. dolthub/dolt#4535, dolthub/dolt#4537), but this change moves us a nice step forward.

Dolt CI Tests:

Fixes:

… where, since SQL standard prevents aliases in where clause
…n aliases (which aren't allowed to be used in where clauses)
…pped and temporarily skipping two failing column alias tests.
@fulghum fulghum changed the title WIP: Alias resolution updates \Alias resolution updates Sep 26, 2022
@fulghum fulghum changed the title \Alias resolution updates Alias resolution updates Sep 26, 2022
@fulghum fulghum marked this pull request as ready for review September 26, 2022 22:42
@fulghum fulghum linked an issue Sep 27, 2022 that may be closed by this pull request
Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only a couple small comments. Thanks for cleaning resolveColumns up, it has been getting increasingly fragile.

sql/analyzer/resolve_columns.go Outdated Show resolved Hide resolved
sql/analyzer/resolve_columns.go Show resolved Hide resolved
sql/analyzer/resolve_columns.go Show resolved Hide resolved
Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, not perfect but steps in the right direction

sql/analyzer/resolve_columns.go Outdated Show resolved Hide resolved
sql/analyzer/resolve_columns.go Show resolved Hide resolved
sql/analyzer/resolve_columns.go Outdated Show resolved Hide resolved
@fulghum fulghum merged commit cff88fe into main Sep 27, 2022
@Hydrocharged Hydrocharged deleted the fulghum/analyzer-aliases branch October 13, 2022 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Column alias in where clause should be an error
3 participants