Skip to content

Commit

Permalink
feat(postgres): implement ArrayColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed May 23, 2022
1 parent 8c96e3c commit 7b0a506
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ibis/backends/postgres/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ def _day_of_week_name(t, expr):
return sa.func.trim(sa.func.to_char(sa_arg, 'Day'))


def _array_column(t, expr):
return postgresql.array(list(map(t.translate, expr.op().cols)))


operation_registry.update(
{
ops.Literal: _literal,
Expand Down Expand Up @@ -676,6 +680,7 @@ def _day_of_week_name(t, expr):
# array operations
ops.ArrayLength: unary(_cardinality),
ops.ArrayCollect: unary(sa.func.array_agg),
ops.ArrayColumn: _array_column,
ops.ArraySlice: _array_slice,
ops.ArrayIndex: fixed_arity(
lambda array, index: array[_neg_idx_to_pos(array, index) + 1], 2
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pytestmark = pytest.mark.never(["sqlite", "mysql"], reason="No array support")


@pytest.mark.notimpl(["impala", "postgres", "clickhouse", "datafusion"])
@pytest.mark.notimpl(["impala", "clickhouse", "datafusion"])
def test_array_column(backend, alltypes, df):
expr = ibis.array([alltypes['double_col'], alltypes['double_col']])
assert isinstance(expr, ir.ArrayColumn)
Expand Down

0 comments on commit 7b0a506

Please sign in to comment.