summaryrefslogtreecommitdiffstats
path: root/sqlglot/optimizer/pushdown_predicates.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-14 05:43:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-14 05:43:02 +0000
commitc8d4d4ead5df1c84966431eec8b88e974414dafc (patch)
tree847e292ab98fe79a3a78cd6797b564b73f4d2681 /sqlglot/optimizer/pushdown_predicates.py
parentReleasing debian version 17.3.0-1. (diff)
downloadsqlglot-c8d4d4ead5df1c84966431eec8b88e974414dafc.tar.xz
sqlglot-c8d4d4ead5df1c84966431eec8b88e974414dafc.zip
Merging upstream version 17.4.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/optimizer/pushdown_predicates.py')
-rw-r--r--sqlglot/optimizer/pushdown_predicates.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/sqlglot/optimizer/pushdown_predicates.py b/sqlglot/optimizer/pushdown_predicates.py
index fb1662d..58b988d 100644
--- a/sqlglot/optimizer/pushdown_predicates.py
+++ b/sqlglot/optimizer/pushdown_predicates.py
@@ -42,7 +42,10 @@ def pushdown_predicates(expression):
# so we limit the selected sources to only itself
for join in select.args.get("joins") or []:
name = join.alias_or_name
- pushdown(join.args.get("on"), {name: scope.selected_sources[name]}, scope_ref_count)
+ if name in scope.selected_sources:
+ pushdown(
+ join.args.get("on"), {name: scope.selected_sources[name]}, scope_ref_count
+ )
return expression