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
Add option to pushdown CTE aliases earlier in qualify #2726
Conversation
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.
Nice PR!
Here's some examples of using the dialect attributes to customize optimizer behavior:
https://github.com/tobymao/sqlglot/blob/main/sqlglot/optimizer/simplify.py#L1095
https://github.com/tobymao/sqlglot/blob/main/sqlglot/optimizer/qualify_columns.py#L43
@barakalon Just took a stab at it - let me know if this is what you intended here but I made it optional and default to what is set in the Dialect if not explicitly passed in. |
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.
A couple more minor comments 👍
Addressed latest round of feedback - let me know if the docs are good. I may have over done it a bit. |
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.
LGTM
I yield to Toby.
Based on Slack conversation with @barakalon we wanted to support the following valid Snowflake query:
where the
HAVING c > 0
is referencing the CTE aliasc