Skip to content

Commit

Permalink
add max scope depth
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 committed Jul 29, 2024
1 parent be92ea0 commit 0e5553a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sqlglot/optimizer/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

TRAVERSABLES = (exp.Query, exp.DDL, exp.DML)

MAX_SCOPE_DEPTH = 200


class ScopeType(Enum):
ROOT = auto()
Expand Down Expand Up @@ -468,6 +470,8 @@ def traverse(self):
scope.subquery_scopes,
)
)
if len(result) > MAX_SCOPE_DEPTH:
raise OptimizeError("Scope depth limit exceeded")

yield from reversed(result)

Expand Down

0 comments on commit 0e5553a

Please sign in to comment.