diff options
Diffstat (limited to 'sqlglot/optimizer/eliminate_subqueries.py')
-rw-r--r-- | sqlglot/optimizer/eliminate_subqueries.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sqlglot/optimizer/eliminate_subqueries.py b/sqlglot/optimizer/eliminate_subqueries.py index e30c263..8704e90 100644 --- a/sqlglot/optimizer/eliminate_subqueries.py +++ b/sqlglot/optimizer/eliminate_subqueries.py @@ -45,7 +45,13 @@ def eliminate_subqueries(expression): # All table names are taken for scope in root.traverse(): - taken.update({source.name: source for _, source in scope.sources.items() if isinstance(source, exp.Table)}) + taken.update( + { + source.name: source + for _, source in scope.sources.items() + if isinstance(source, exp.Table) + } + ) # Map of Expression->alias # Existing CTES in the root expression. We'll use this for deduplication. @@ -70,7 +76,9 @@ def eliminate_subqueries(expression): new_ctes.append(cte_scope.expression.parent) # Now append the rest - for scope in itertools.chain(root.union_scopes, root.subquery_scopes, root.derived_table_scopes): + for scope in itertools.chain( + root.union_scopes, root.subquery_scopes, root.derived_table_scopes + ): for child_scope in scope.traverse(): new_cte = _eliminate(child_scope, existing_ctes, taken) if new_cte: |