Skip to content

Commit

Permalink
feat(duckdb): implement ops.StructColumn operation
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 19, 2022
1 parent 020bfdb commit 211bfab
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ibis/backends/duckdb/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ def _string_agg(t, expr):
return agg


def _struct_column(t, expr):
op = expr.op()
compile_kwargs = dict(literal_binds=True)
translated_pairs = (
(name, t.translate(value).compile(compile_kwargs=compile_kwargs))
for name, value in zip(op.names, op.values)
)
return sa.func.struct_pack(
*(sa.text(f"{name} := {value}") for name, value in translated_pairs)
)


operation_registry.update(
{
ops.ArrayColumn: _array_column,
Expand Down Expand Up @@ -212,6 +224,7 @@ def _string_agg(t, expr):
ops.Strftime: _strftime,
ops.Arbitrary: _arbitrary,
ops.GroupConcat: _string_agg,
ops.StructColumn: _struct_column,
}
)

Expand Down

0 comments on commit 211bfab

Please sign in to comment.