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

fix(snowflake): Allow alias expansion inside JOIN statements #4504

Conversation

florian-ernst-alan
Copy link
Contributor

Fixes #4502

@florian-ernst-alan
Copy link
Contributor Author

Dammit, missed the formatting checks locally. I'll fix tomorrow, it's 8PM here.

Comment on lines +69 to 70
dialect,
expand_only_groupby=dialect.EXPAND_ALIAS_REFS_EARLY_ONLY_IN_GROUP_BY,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Passing dialect here means we can refactor the expand_only_groupby flag as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing that actually make some BigQuery tests fail, because this call line 77

        if not schema.empty and expand_alias_refs:
            _expand_alias_refs(scope, resolver, dialect)

alwasy has expand_only_groupby=False regardless of the dialect.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, makes sense. Should we refactor this PR then to introduce a similar constant and an arg like expand_joins?

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

Probably fine as is.

Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
@georgesittas georgesittas requested a review from tobymao December 12, 2024 14:22
@georgesittas georgesittas merged commit 2b68b9b into tobymao:main Dec 12, 2024
7 checks passed
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.

[Snowflake] sqlglot.optimizer.qualify.qualify does not resolve SELECT columns inside JOINs
2 participants