summaryrefslogtreecommitdiffstats
path: root/sqlglot/optimizer/isolate_table_selects.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/optimizer/isolate_table_selects.py')
-rw-r--r--sqlglot/optimizer/isolate_table_selects.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/sqlglot/optimizer/isolate_table_selects.py b/sqlglot/optimizer/isolate_table_selects.py
index 79e3ed5..a6524b8 100644
--- a/sqlglot/optimizer/isolate_table_selects.py
+++ b/sqlglot/optimizer/isolate_table_selects.py
@@ -12,7 +12,12 @@ def isolate_table_selects(expression, schema=None):
continue
for _, source in scope.selected_sources.values():
- if not isinstance(source, exp.Table) or not schema.column_names(source):
+ if (
+ not isinstance(source, exp.Table)
+ or not schema.column_names(source)
+ or isinstance(source.parent, exp.Subquery)
+ or isinstance(source.parent.parent, exp.Table)
+ ):
continue
if not source.alias: