-
Notifications
You must be signed in to change notification settings - Fork 96
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
Support generation of CTEs in DataflowToSqlQueryPlanConverter
#1521
Conversation
optimizers=option_set.optimizers, | ||
) | ||
|
||
def convert_using_specifics( |
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.
Need a better name for this one.
SqlColumnPrunerOptimizer(), | ||
SqlRewritingSubQueryReducer(use_column_alias_in_group_bys=use_column_alias_in_group_by), | ||
SqlTableAliasSimplifier(), | ||
) | ||
allow_cte = True |
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.
Isn't this an optimizer? Why treat it differently? Did you turn it into an optimizer in a later PR or did I hallucinate that? 🤔
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 one is a little different from the SQL optimizers because it changes how the dataflow plan converts to the SQL plan. The SQL optimizers convert a SQL plan to another SQL plan. Might have been a similar class you saw?
logger.debug(LazyFormat("Converting to SQL", nodes_to_convert_to_cte=nodes_to_convert_to_cte)) | ||
|
||
if len(nodes_to_convert_to_cte) == 0: | ||
# Avoid `DataflowNodeToSqlCteVisitor` code path for better isolation during rollout. |
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.
Thanks for clarifying this 👍
This PR:
SqlGenerationOptionSet
to encapsulate the options for how SQL should be generated from the dataflow plan.O5
level that uses all previous optimizers and generates CTEs.DataflowToSqlQueryPlanConverter
to useSqlGenerationOptionSet
. When theallow_cte
option it set, converts the common nodes (as implemented in Add a method to figure out common nodes in a dataflow plan #1520) in a dataflow plan to map to a CTE instead of a subquery.Since CTEs are not generated by default, the generated SQL is the same for test cases and there are no snapshot changes (aside from the ones that specifically test this feature).