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

Refactor!(optimizer): only create scopes for the DDL queries #3096

Merged
merged 6 commits into from
Mar 8, 2024

Conversation

georgesittas
Copy link
Collaborator

We used to create Scopes for both Query and DDL expressions, but the logic that handled the latter was brittle, incomplete and resulted in another expression type that users of the Scope module had to take into account, thus making the interface more complex to use.

This makes it so that we'll only optimize the queries of statements such as CTAS and INSERT INTO, instead of the whole thing. Same holds for lineage inference - we'll only analyze the DDL queries.

Fixes #3086

We used to create Scopes for both Query and DDL expressions, but the
logic that handled the latter was brittle, incomplete and resulted in
another expression type that users of the Scope module had to take
into account, thus making the interface more complex to use.

This makes it so that we'll only optimize the _queries_ of statements
such as CTAS and INSERT INTO, instead of the whole thing. Same holds
for lineage inference - we'll only analyze the DDL queries.
sqlglot/transforms.py Outdated Show resolved Hide resolved
sqlglot/optimizer/qualify.py Outdated Show resolved Hide resolved
@georgesittas georgesittas changed the title Refactor!(optimizer): don't create scopes for DDLs Refactor!(optimizer): only create scopes for the DDL queries Mar 8, 2024
@georgesittas georgesittas merged commit 8a34fb4 into main Mar 8, 2024
5 checks passed
@georgesittas georgesittas deleted the jo/fix_ddl_scope branch March 8, 2024 00:26
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.

Lineage - not downstreaming to subquery expression
3 participants