diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-10-21 09:29:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-10-21 09:29:26 +0000 |
commit | 8b4272814fb4585be120f183eb7c26bb8acde974 (patch) | |
tree | 85d56a8f5ac4ac94ab924d5bbc578586eeb2a998 /sqlglot/optimizer/isolate_table_selects.py | |
parent | Releasing debian version 7.1.3-1. (diff) | |
download | sqlglot-8b4272814fb4585be120f183eb7c26bb8acde974.tar.xz sqlglot-8b4272814fb4585be120f183eb7c26bb8acde974.zip |
Merging upstream version 9.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | sqlglot/optimizer/isolate_table_selects.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sqlglot/optimizer/isolate_table_selects.py b/sqlglot/optimizer/isolate_table_selects.py index e060739..652cdef 100644 --- a/sqlglot/optimizer/isolate_table_selects.py +++ b/sqlglot/optimizer/isolate_table_selects.py @@ -12,18 +12,16 @@ def isolate_table_selects(expression): if not isinstance(source, exp.Table): continue - if not isinstance(source.parent, exp.Alias): + if not source.alias: raise OptimizeError("Tables require an alias. Run qualify_tables optimization.") - parent = source.parent - - parent.replace( + source.replace( exp.select("*") .from_( - alias(source, source.name or parent.alias, table=True), + alias(source.copy(), source.name or source.alias, table=True), copy=False, ) - .subquery(parent.alias, copy=False) + .subquery(source.alias, copy=False) ) return expression |