diff options
Diffstat (limited to '')
-rw-r--r-- | sqlglot/optimizer/pushdown_predicates.py | 5 |
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 |