Skip to content

Commit

Permalink
Fix: array_join -> concat_ws closes #1558
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed May 5, 2023
1 parent 951d407 commit ac60698
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/dialects/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class Generator(generator.Generator):
exp.Property: _property_sql,
exp.ApproxDistinct: approx_count_distinct_sql,
exp.ArrayConcat: rename_func("CONCAT"),
exp.ArrayJoin: lambda self, e: self.func("CONCAT_WS", e.expression, e.this),
exp.ArraySize: rename_func("SIZE"),
exp.ArraySort: _array_sort_sql,
exp.With: no_recursive_cte_sql,
Expand Down
1 change: 1 addition & 0 deletions sqlglot/dialects/spark2.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class Generator(Hive.Generator):
exp.WeekOfYear: rename_func("WEEKOFYEAR"),
exp.AtTimeZone: lambda self, e: f"FROM_UTC_TIMESTAMP({self.sql(e, 'this')}, {self.sql(e, 'zone')})",
}
TRANSFORMS.pop(exp.ArrayJoin)
TRANSFORMS.pop(exp.ArraySort)
TRANSFORMS.pop(exp.ILike)

Expand Down
7 changes: 7 additions & 0 deletions tests/dialects/test_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ def test_regex(self):
"spark": "SIZE(x)",
},
)
self.validate_all(
"ARRAY_JOIN(x, '-', 'a')",
write={
"hive": "CONCAT_WS('-', x)",
"spark": "ARRAY_JOIN(x, '-', 'a')",
},
)

def test_interval_plural_to_singular(self):
# Microseconds, weeks and quarters are not supported in Presto/Trino INTERVAL literals
Expand Down

0 comments on commit ac60698

Please sign in to comment.