diff options
Diffstat (limited to '')
-rw-r--r-- | sqlglot/optimizer/optimizer.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sqlglot/optimizer/optimizer.py b/sqlglot/optimizer/optimizer.py index 72e67d4..46b6b30 100644 --- a/sqlglot/optimizer/optimizer.py +++ b/sqlglot/optimizer/optimizer.py @@ -15,6 +15,7 @@ from sqlglot.optimizer.pushdown_projections import pushdown_projections from sqlglot.optimizer.qualify_columns import qualify_columns from sqlglot.optimizer.qualify_tables import qualify_tables from sqlglot.optimizer.unnest_subqueries import unnest_subqueries +from sqlglot.schema import ensure_schema RULES = ( lower_identities, @@ -51,12 +52,13 @@ def optimize(expression, schema=None, db=None, catalog=None, rules=RULES, **kwar If no schema is provided then the default schema defined at `sqlgot.schema` will be used db (str): specify the default database, as might be set by a `USE DATABASE db` statement catalog (str): specify the default catalog, as might be set by a `USE CATALOG c` statement - rules (list): sequence of optimizer rules to use + rules (sequence): sequence of optimizer rules to use **kwargs: If a rule has a keyword argument with a same name in **kwargs, it will be passed in. Returns: sqlglot.Expression: optimized expression """ - possible_kwargs = {"db": db, "catalog": catalog, "schema": schema or sqlglot.schema, **kwargs} + schema = ensure_schema(schema or sqlglot.schema) + possible_kwargs = {"db": db, "catalog": catalog, "schema": schema, **kwargs} expression = expression.copy() for rule in rules: |