From 41698ed09f18c2ec13c29e571586f17d3cf0edbf Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Sat, 21 Jan 2023 07:08:30 -0500 Subject: [PATCH] feat(snowflake): implement `ops.StructColumn` --- ibis/backends/snowflake/registry.py | 3 +++ ibis/backends/tests/test_struct.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ibis/backends/snowflake/registry.py b/ibis/backends/snowflake/registry.py index dc47435b8d9c..0b2244166134 100644 --- a/ibis/backends/snowflake/registry.py +++ b/ibis/backends/snowflake/registry.py @@ -260,6 +260,9 @@ def _arbitrary(t, op): ), ops.NthValue: _nth_value, ops.Arbitrary: _arbitrary, + ops.StructColumn: lambda t, op: sa.func.object_construct_keep_null( + *itertools.chain.from_iterable(zip(op.names, map(t.translate, op.values))) + ), } ) diff --git a/ibis/backends/tests/test_struct.py b/ibis/backends/tests/test_struct.py index e5a2a897cdf9..e5683079f05b 100644 --- a/ibis/backends/tests/test_struct.py +++ b/ibis/backends/tests/test_struct.py @@ -75,7 +75,7 @@ def test_null_literal(con, field): tm.assert_series_equal(result, expected) -@pytest.mark.notimpl(["dask", "pandas", "postgres", "snowflake"]) +@pytest.mark.notimpl(["dask", "pandas", "postgres"]) def test_struct_column(alltypes, df): t = alltypes expr = ibis.struct(dict(a=t.string_col, b=1, c=t.bigint_col)).name("s")