Skip to content

Commit 3e06f0a

Browse files
committed
PR Feedback 1
1 parent b1e3086 commit 3e06f0a

3 files changed

Lines changed: 8 additions & 11 deletions

File tree

sqlmesh/core/engine_adapter/base.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ def execute(
21402140
with self.transaction():
21412141
for e in ensure_list(expressions):
21422142
if isinstance(e, exp.Expression):
2143-
self._check_identifier_length(e, check_only_ddl=True)
2143+
self._check_identifier_length(e)
21442144
sql = self._to_sql(e, quote=quote_identifiers, **to_sql_kwargs)
21452145
else:
21462146
sql = t.cast(str, e)
@@ -2515,20 +2515,16 @@ def ping(self) -> None:
25152515
def _select_columns(cls, columns: t.Iterable[str]) -> exp.Select:
25162516
return exp.select(*(exp.column(c, quoted=True) for c in columns))
25172517

2518-
def _check_identifier_length(
2519-
self, expression: exp.Expression, check_only_ddl: bool = True
2520-
) -> None:
2521-
if self.MAX_IDENTIFIER_LENGTH is None or (
2522-
check_only_ddl and not isinstance(expression, exp.DDL)
2523-
):
2518+
def _check_identifier_length(self, expression: exp.Expression) -> None:
2519+
if self.MAX_IDENTIFIER_LENGTH is None or not isinstance(expression, exp.DDL):
25242520
return
25252521

25262522
for identifier in expression.find_all(exp.Identifier):
25272523
name = identifier.name
25282524
name_length = len(name)
25292525
if name_length > self.MAX_IDENTIFIER_LENGTH:
25302526
raise SQLMeshError(
2531-
f"Identifier name {name} (length {name_length}) exceeds {self.dialect.capitalize()}'s max identifier limit of {self.MAX_IDENTIFIER_LENGTH} characters"
2527+
f"Identifier name '{name}' (length {name_length}) exceeds {self.dialect.capitalize()}'s max identifier limit of {self.MAX_IDENTIFIER_LENGTH} characters"
25322528
)
25332529

25342530

sqlmesh/core/engine_adapter/risingwave.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class RisingwaveEngineAdapter(PostgresEngineAdapter):
3030
COMMENT_CREATION_VIEW = CommentCreationView.UNSUPPORTED
3131
SUPPORTS_MATERIALIZED_VIEWS = True
3232
SUPPORTS_TRANSACTIONS = False
33+
MAX_IDENTIFIER_LENGTH = None
3334

3435
def _truncate_table(self, table_name: TableName) -> None:
3536
return self.execute(exp.Delete(this=exp.to_table(table_name)))

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os
55
import pathlib
6+
import re
67
import sys
78
import typing as t
89
import shutil
@@ -1571,7 +1572,6 @@ def test_init_project(ctx: TestContext, tmp_path_factory: pytest.TempPathFactory
15711572

15721573
# normalize object names for snowflake
15731574
if ctx.dialect == "snowflake":
1574-
import re
15751575

15761576
def _normalize_snowflake(name: str, prefix_regex: str = "(sqlmesh__)(.*)"):
15771577
match = re.search(prefix_regex, name)
@@ -1789,7 +1789,6 @@ def test_to_time_column(
17891789
# Clickhouse does not have natively timezone-aware types and does not accept timestrings
17901790
# with UTC offset "+XX:XX". Therefore, we remove the timezone offset and set a timezone-
17911791
# specific data type to validate what is returned.
1792-
import re
17931792

17941793
time_column = re.match(r"^(.*?)\+", time_column).group(1)
17951794
time_column_type = exp.DataType.build("TIMESTAMP('UTC')", dialect="clickhouse")
@@ -2661,8 +2660,9 @@ def test_identifier_length_limit(ctx: TestContext):
26612660

26622661
long_table_name = "a" * (adapter.MAX_IDENTIFIER_LENGTH + 1)
26632662

2663+
match = f"Identifier name '{long_table_name}' (length {len(long_table_name)}) exceeds {adapter.dialect.capitalize()}'s max identifier limit of {adapter.MAX_IDENTIFIER_LENGTH} characters"
26642664
with pytest.raises(
26652665
SQLMeshError,
2666-
match=f"Identifier name {long_table_name} (length {len(long_table_name)}) exceeds {adapter.dialect.capitalize()}'s max identifier limit of {adapter.MAX_IDENTIFIER_LENGTH} characters",
2666+
match=re.escape(match),
26672667
):
26682668
adapter.create_table(long_table_name, {"col": exp.DataType.build("int")})

0 commit comments

Comments
 (0)