Skip to content

Commit b666137

Browse files
committed
remove unnecessary support for older sqlglot versions
1 parent 30cd7a1 commit b666137

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

sqlmesh/core/engine_adapter/base.py

Lines changed: 2 additions & 3 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) or query.args.pop("with", None)
2864+
with_ = 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,8 +2877,7 @@ def _order_projections_and_filter(
28772877
query = query.where(where, copy=False)
28782878

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

28832882
return query
28842883

sqlmesh/core/metric/rewriter.py

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

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

sqlmesh/core/model/definition.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,7 @@ 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-
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:
756+
if isinstance(select_or_set_op, exp.Select) and select_or_set_op.args.get("from_"):
758757
select_or_set_op.where(exp.false(), copy=False)
759758

760759
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_") or query.args.get("with")
714+
with_clause = 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_") or model_query.args.get("with")
908+
with_clause = model_query.args.get("with_")
909909

910910
if with_clause and include_ctes:
911911
ctes = {}

0 commit comments

Comments
 (0)