Skip to content

Commit 1301f18

Browse files
cpcloudkszucs
authored andcommitted
feat(clickhouse): implement ArrayColumn
1 parent 7b0a506 commit 1301f18

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ibis/backends/clickhouse/registry.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ def compile(translator, expr):
609609
return compile
610610

611611

612+
def _array_column(t, expr):
613+
args = ", ".join(map(t.translate, expr.op().cols))
614+
return f"[{args}]"
615+
616+
612617
# TODO: clickhouse uses different string functions
613618
# for ascii and utf-8 encodings,
614619

@@ -762,6 +767,7 @@ def compile(translator, expr):
762767
ops.Degrees: _unary("degrees"),
763768
ops.Radians: _unary("radians"),
764769
ops.Strftime: _fixed_arity("formatDateTime", 2),
770+
ops.ArrayColumn: _array_column,
765771
}
766772

767773

ibis/backends/tests/test_array.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010
pytestmark = pytest.mark.never(["sqlite", "mysql"], reason="No array support")
1111

1212

13-
@pytest.mark.notimpl(["impala", "clickhouse", "datafusion"])
13+
@pytest.mark.notimpl(["impala", "datafusion"])
1414
def test_array_column(backend, alltypes, df):
1515
expr = ibis.array([alltypes['double_col'], alltypes['double_col']])
1616
assert isinstance(expr, ir.ArrayColumn)
1717

1818
result = expr.execute()
1919
expected = df.apply(
20-
lambda row: np.array(
21-
[row['double_col'], row['double_col']], dtype=object
22-
),
20+
lambda row: [row['double_col'], row['double_col']],
2321
axis=1,
2422
)
2523
backend.assert_series_equal(result, expected, check_names=False)

0 commit comments

Comments
 (0)