Skip to content

Commit 9d3a929

Browse files
committed
Fix: preserve ARRAY_JOIN for StarRocks, Doris (fixes #5095)
1 parent b63b60e commit 9d3a929

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

sqlglot/dialects/doris.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Generator(MySQL.Generator):
5959
exp.ArgMax: rename_func("MAX_BY"),
6060
exp.ArgMin: rename_func("MIN_BY"),
6161
exp.ArrayAgg: rename_func("COLLECT_LIST"),
62+
exp.ArrayToString: rename_func("ARRAY_JOIN"),
6263
exp.ArrayUniqueAgg: rename_func("COLLECT_SET"),
6364
exp.CurrentTimestamp: lambda self, _: self.func("NOW"),
6465
exp.DateTrunc: lambda self, e: self.func("DATE_TRUNC", e.this, unit_to_str(e)),

sqlglot/dialects/starrocks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class Generator(MySQL.Generator):
132132
TRANSFORMS = {
133133
**MySQL.Generator.TRANSFORMS,
134134
exp.Array: inline_array_sql,
135+
exp.ArrayToString: rename_func("ARRAY_JOIN"),
135136
exp.ApproxDistinct: approx_count_distinct_sql,
136137
exp.DateDiff: lambda self, e: self.func(
137138
"DATE_DIFF", unit_to_str(e), e.this, e.expression

tests/dialects/test_starrocks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class TestStarrocks(Validator):
66
dialect = "starrocks"
77

88
def test_starrocks(self):
9+
self.validate_identity("SELECT ARRAY_JOIN([1, 3, 5, NULL], '_', 'NULL')")
10+
self.validate_identity("SELECT ARRAY_JOIN([1, 3, 5, NULL], '_')")
911
self.validate_identity("ALTER TABLE a SWAP WITH b")
1012

1113
def test_ddl(self):

0 commit comments

Comments
 (0)