Skip to content

Commit 69e810b

Browse files
authored
Chore!: fix mypy issues, use _parse_table_parts instead of _parse_table (#903)
* Chore!: fix mypy issues, use _parse_table_parts instead of _parse_table * Bump sqlglot * Fix index creation
1 parent 598dfbd commit 69e810b

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"requests",
4545
"rich",
4646
"ruamel.yaml",
47-
"sqlglot~=14.0.0",
47+
"sqlglot~=14.1.0",
4848
"fsspec",
4949
],
5050
extras_require={

sqlmesh/core/dialect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def parse(self: Parser) -> t.Optional[exp.Expression]:
236236
value: t.Optional[exp.Expression | str]
237237

238238
if key in table_keys:
239-
value = exp.table_name(self._parse_table())
239+
value = exp.table_name(self._parse_table_parts())
240240
elif key == "columns":
241241
value = self._parse_schema()
242242
elif key == "kind":

sqlmesh/core/engine_adapter/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,12 @@ def create_index(
168168
"""
169169
if not self.SUPPORTS_INDEXES:
170170
return
171+
171172
expression = exp.Create(
172173
this=exp.Index(
173174
this=exp.to_identifier(index_name),
174175
table=exp.to_table(table_name),
175-
columns=exp.Tuple(
176-
expressions=[exp.to_column(c) for c in columns],
177-
),
176+
columns=[exp.to_column(c) for c in columns],
178177
),
179178
kind="INDEX",
180179
exists=exists,

sqlmesh/core/renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def _expand(node: exp.Expression) -> exp.Expression:
250250
query.set("with", with_)
251251

252252
if mapping:
253-
return exp.replace_tables(query, mapping)
253+
return exp.replace_tables(t.cast(exp.Subqueryable, query), mapping)
254254

255255
if not isinstance(query, exp.Subqueryable):
256256
raise_config_error(f"Query needs to be a SELECT or a UNION {query}.", self._path)

tests/core/test_macros.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import typing as t
2+
13
import pytest
24
from sqlglot import exp, parse_one
35

@@ -9,7 +11,7 @@
911
def filter_country(
1012
evaluator: MacroEvaluator, expression: exp.Condition, country: str
1113
) -> exp.Condition:
12-
return exp.and_(expression, exp.column("country").eq(country))
14+
return t.cast(exp.Condition, exp.and_(expression, exp.column("country").eq(country)))
1315

1416

1517
@macro("UPPER")

0 commit comments

Comments
 (0)