summaryrefslogtreecommitdiffstats
path: root/sqlglot/optimizer/eliminate_ctes.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/optimizer/eliminate_ctes.py')
-rw-r--r--sqlglot/optimizer/eliminate_ctes.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/sqlglot/optimizer/eliminate_ctes.py b/sqlglot/optimizer/eliminate_ctes.py
index 6f1865c..d2e876c 100644
--- a/sqlglot/optimizer/eliminate_ctes.py
+++ b/sqlglot/optimizer/eliminate_ctes.py
@@ -32,7 +32,7 @@ def eliminate_ctes(expression):
cte_node.pop()
# Pop the entire WITH clause if this is the last CTE
- if len(with_node.expressions) <= 0:
+ if with_node and len(with_node.expressions) <= 0:
with_node.pop()
# Decrement the ref count for all sources this CTE selects from