Skip to content

Commit 1767205

Browse files
committed
feat(clickhouse): implement string concat for clickhouse
1 parent 77a8eb9 commit 1767205

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

ibis/backends/clickhouse/registry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,12 @@ def _string_join(translator, expr):
551551
)
552552

553553

554+
def _string_concat(translator, expr):
555+
args = expr.op().arg
556+
args_formatted = ", ".join(map(translator.translate, args))
557+
return f"arrayStringConcat([{args_formatted}])"
558+
559+
554560
def _string_like(translator, expr):
555561
value, pattern = expr.op().args[:2]
556562
return '{} LIKE {}'.format(
@@ -662,6 +668,7 @@ def _string_right(translator, expr):
662668
ops.RStrip: _unary('trimRight'),
663669
ops.Strip: _unary('trimBoth'),
664670
ops.Repeat: _fixed_arity("repeat", 2),
671+
ops.StringConcat: _string_concat,
665672
ops.RegexSearch: _fixed_arity('match', 2),
666673
# TODO: extractAll(haystack, pattern)[index + 1]
667674
ops.RegexExtract: _regex_extract,

ibis/backends/sqlite/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def _string_join(t, expr):
289289
sep, elements = expr.op().args
290290
return functools.reduce(
291291
operator.add,
292-
map(t.translate, toolz.interpose(sep, elements)),
292+
toolz.interpose(t.translate(sep), map(t.translate, elements)),
293293
)
294294

295295

ibis/backends/tests/test_string.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def is_text_type(x):
99
return isinstance(x, str)
1010

1111

12-
def test_string_col_is_unicode(backend, alltypes, df):
12+
def test_string_col_is_unicode(alltypes, df):
1313
dtype = alltypes.string_col.type()
1414
assert dtype == dt.String(nullable=dtype.nullable)
1515
assert df.string_col.map(is_text_type).all()
@@ -262,24 +262,25 @@ def test_string_col_is_unicode(backend, alltypes, df):
262262
lambda t: ibis.literal('-').join(['a', t.string_col, 'c']),
263263
lambda t: 'a-' + t.string_col + '-c',
264264
id='join',
265+
marks=pytest.mark.notimpl(["datafusion"]),
265266
),
266267
param(
267268
lambda t: t.string_col + t.date_string_col,
268269
lambda t: t.string_col + t.date_string_col,
269270
id='concat_columns',
270-
marks=pytest.mark.notimpl(["datafusion", "clickhouse"]),
271+
marks=pytest.mark.notimpl(["datafusion", "impala"]),
271272
),
272273
param(
273274
lambda t: t.string_col + 'a',
274275
lambda t: t.string_col + 'a',
275276
id='concat_column_scalar',
276-
marks=pytest.mark.notimpl(["datafusion", "clickhouse"]),
277+
marks=pytest.mark.notimpl(["datafusion", "impala"]),
277278
),
278279
param(
279280
lambda t: 'a' + t.string_col,
280281
lambda t: 'a' + t.string_col,
281282
id='concat_scalar_column',
282-
marks=pytest.mark.notimpl(["datafusion", "clickhouse"]),
283+
marks=pytest.mark.notimpl(["datafusion", "impala"]),
283284
),
284285
],
285286
)

ibis/backends/tests/test_temporal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ def convert_to_offset(offset, displacement_type=displacement_type):
269269
# TODO - DateOffset - #2553
270270
@pytest.mark.notimpl(
271271
[
272-
"clickhouse",
273272
"dask",
274273
"datafusion",
275274
"impala",

0 commit comments

Comments
 (0)