Skip to content

Commit 0390776

Browse files
committed
modify code according some small change of sqlglot
Signed-off-by: jaogoy <jaogoy@gmail.com>
1 parent 6ebdfbc commit 0390776

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

sqlmesh/core/engine_adapter/starrocks.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ def _build_partitioned_by_exp(
28822882
create_expressions=create_expressions,
28832883
)
28842884
elif partition_kind is None:
2885-
return exp.PartitionedByProperty(this=exp.tuple_(*partitioned_by))
2885+
return exp.PartitionedByProperty(this=exp.Schema(expressions=partitioned_by))
28862886

28872887
return None
28882888

@@ -2947,13 +2947,12 @@ def _build_distributed_by_property(
29472947
expressions_list.append(exp.to_column(str(col)))
29482948
# Build buckets expression
29492949
buckets: t.Optional[t.Any] = unified.get("buckets")
2950+
buckets_expr: t.Optional[exp.Expression] = None
29502951
if buckets is not None:
29512952
if isinstance(buckets, exp.Literal):
29522953
buckets_expr = buckets
29532954
else:
29542955
buckets_expr = exp.Literal.number(int(buckets))
2955-
else:
2956-
buckets_expr = None
29572956

29582957
result = exp.DistributedByProperty(
29592958
kind=kind_expr,
@@ -2986,7 +2985,7 @@ def _build_refresh_property(
29862985
# method is required by exp.RefreshTriggerProperty, but StarRocks syntax does NOT support AUTO.
29872986
# We use a sentinel value that the StarRocks generator will not render (it only renders
29882987
# IMMEDIATE/DEFERRED).
2989-
method_expr = exp.Var(this="UNSPECIFIED")
2988+
method_expr = None
29902989
if refresh_moment is not None:
29912990
refresh_moment_text = PropertyValidator.validate_and_normalize_property(
29922991
"refresh_moment", refresh_moment

tests/core/engine_adapter/test_starrocks.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,11 @@ class TestPartitionPropertyBuilding:
813813
# Expression partitioning - multi-column
814814
("(year, month)", "PARTITION BY `year`, `month`", "PARTITION BY (`year`, `month`)"),
815815
# Expression partitioning - multi-column with func
816-
("(date_trunc('day', dt), region)", "PARTITION BY DATE_TRUNC('DAY', `dt`), `region`", None),
816+
(
817+
"(date_trunc('day', dt), region)",
818+
"PARTITION BY DATE_TRUNC('DAY', `dt`), `region`",
819+
None,
820+
),
817821
# RANGE partitioning
818822
("RANGE (dt)", "PARTITION BY RANGE (`dt`) ()", None),
819823
# LIST partitioning
@@ -967,7 +971,11 @@ def test_partitioned_by_as_model_parameter(
967971
)
968972

969973
sql = to_sql_calls(adapter)[0]
970-
assert "PARTITION BY (year, month)" in sql or "PARTITION BY `year`, `month`" in sql or "PARTITION BY (`year`, `month`)" in sql
974+
assert (
975+
"PARTITION BY (year, month)" in sql
976+
or "PARTITION BY `year`, `month`" in sql
977+
or "PARTITION BY (`year`, `month`)" in sql
978+
)
971979

972980
def test_partitions_value_forms(
973981
self, make_mocked_engine_adapter: t.Callable[..., StarRocksEngineAdapter]

0 commit comments

Comments
 (0)