Skip to content

Commit 30cd7a1

Browse files
committed
bump sqlglot to 28.6.0
1 parent a5544e2 commit 30cd7a1

File tree

20 files changed

+79
-81
lines changed

20 files changed

+79
-81
lines changed

examples/sushi/models/customers.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ LEFT JOIN (
4242
ON o.customer_id = m.customer_id
4343
LEFT JOIN raw.demographics AS d
4444
ON o.customer_id = d.customer_id
45-
WHERE sushi.orders.customer_id > 0
45+
WHERE o.customer_id > 0

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies = [
2424
"requests",
2525
"rich[jupyter]",
2626
"ruamel.yaml",
27-
"sqlglot[rs]~=27.28.0",
27+
"sqlglot[rs]~=28.6.0",
2828
"tenacity",
2929
"time-machine",
3030
"json-stream"

sqlmesh/core/config/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ def init(cursor: t.Any) -> None:
23342334
for tpe in subclasses(
23352335
__name__,
23362336
ConnectionConfig,
2337-
exclude=(ConnectionConfig, BaseDuckDBConnectionConfig),
2337+
exclude={ConnectionConfig, BaseDuckDBConnectionConfig},
23382338
)
23392339
}
23402340

@@ -2343,7 +2343,7 @@ def init(cursor: t.Any) -> None:
23432343
for tpe in subclasses(
23442344
__name__,
23452345
ConnectionConfig,
2346-
exclude=(ConnectionConfig, BaseDuckDBConnectionConfig),
2346+
exclude={ConnectionConfig, BaseDuckDBConnectionConfig},
23472347
)
23482348
}
23492349

@@ -2355,7 +2355,7 @@ def init(cursor: t.Any) -> None:
23552355
for tpe in subclasses(
23562356
__name__,
23572357
ConnectionConfig,
2358-
exclude=(ConnectionConfig, BaseDuckDBConnectionConfig),
2358+
exclude={ConnectionConfig, BaseDuckDBConnectionConfig},
23592359
)
23602360
}
23612361

sqlmesh/core/config/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_default_catalog_per_gateway(self, context: GenericContext) -> t.Dict[str
146146

147147
SCHEDULER_CONFIG_TO_TYPE = {
148148
tpe.all_field_infos()["type_"].default: tpe
149-
for tpe in subclasses(__name__, BaseConfig, exclude=(BaseConfig,))
149+
for tpe in subclasses(__name__, BaseConfig, exclude={BaseConfig})
150150
}
151151

152152

sqlmesh/core/engine_adapter/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ def _order_projections_and_filter(
28612861
return query
28622862

28632863
query = t.cast(exp.Query, query.copy())
2864-
with_ = query.args.pop("with", None)
2864+
with_ = query.args.pop("with_", None) or query.args.pop("with", None)
28652865

28662866
select_exprs: t.List[exp.Expression] = [
28672867
exp.column(c, quoted=True) for c in target_columns_to_types
@@ -2877,7 +2877,8 @@ def _order_projections_and_filter(
28772877
query = query.where(where, copy=False)
28782878

28792879
if with_:
2880-
query.set("with", with_)
2880+
with_key = "with_" if "with_" in query.arg_types else "with"
2881+
query.set(with_key, with_)
28812882

28822883
return query
28832884

sqlmesh/core/linter/rules/builtin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,4 @@ def check_model(self, model: Model) -> t.Optional[RuleViolation]:
318318
return None
319319

320320

321-
BUILTIN_RULES = RuleSet(subclasses(__name__, Rule, (Rule,)))
321+
BUILTIN_RULES = RuleSet(subclasses(__name__, Rule, exclude={Rule}))

sqlmesh/core/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ def _load_linting_rules(self) -> RuleSet:
840840
if os.path.getsize(path):
841841
self._track_file(path)
842842
module = import_python_file(path, self.config_path)
843-
module_rules = subclasses(module.__name__, Rule, (Rule,))
843+
module_rules = subclasses(module.__name__, Rule, exclude={Rule})
844844
for user_rule in module_rules:
845845
user_rules[user_rule.name] = user_rule
846846

sqlmesh/core/metric/rewriter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def _build_sources(self, projections: t.List[exp.Expression]) -> SourceAggsAndJo
5757
return sources
5858

5959
def _expand(self, select: exp.Select) -> None:
60-
base = select.args["from"].this.find(exp.Table)
60+
from_clause = t.cast(exp.From, select.args.get("from") or select.args.get("from_"))
61+
base = from_clause.this.find(exp.Table)
6162
base_alias = base.alias_or_name
6263
base_name = exp.table_name(base)
6364

sqlmesh/core/model/definition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ def ctas_query(self, **render_kwarg: t.Any) -> exp.Query:
753753
query = self.render_query_or_raise(**render_kwarg).limit(0)
754754

755755
for select_or_set_op in query.find_all(exp.Select, exp.SetOperation):
756-
if isinstance(select_or_set_op, exp.Select) and select_or_set_op.args.get("from"):
756+
from_clause = select_or_set_op.args.get("from") or select_or_set_op.args.get("from_")
757+
if isinstance(select_or_set_op, exp.Select) and from_clause:
757758
select_or_set_op.where(exp.false(), copy=False)
758759

759760
if self.managed_columns:

sqlmesh/core/test/definition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def runTest(self) -> None:
711711
query = self._render_model_query()
712712
sql = query.sql(self._test_adapter_dialect, pretty=self.engine_adapter._pretty_sql)
713713

714-
with_clause = query.args.get("with")
714+
with_clause = query.args.get("with_") or query.args.get("with")
715715

716716
if with_clause:
717717
self.test_ctes(
@@ -905,7 +905,7 @@ def generate_test(
905905
if isinstance(model, SqlModel):
906906
assert isinstance(test, SqlModelTest)
907907
model_query = test._render_model_query()
908-
with_clause = model_query.args.get("with")
908+
with_clause = model_query.args.get("with_") or model_query.args.get("with")
909909

910910
if with_clause and include_ctes:
911911
ctes = {}

0 commit comments

Comments
 (0)