Skip to content

Commit

Permalink
test(backend): add ops.StructColumn test
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 19, 2022
1 parent 7ad27f0 commit a216c18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ibis/backends/tests/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pytest import param

import ibis
import ibis.expr.datatypes as dt

pytestmark = [
pytest.mark.never(["mysql", "sqlite"], reason="No struct support"),
Expand Down Expand Up @@ -67,3 +68,19 @@ def test_literal(con, field, expr_fn, expected_fn):
result = pd.Series([con.execute(query)]).replace(np.nan, None)
expected = pd.Series([expected_fn(field)])
tm.assert_series_equal(result, expected)


@pytest.mark.notimpl(["dask", "pandas", "postgres"])
def test_struct_column(con):
t = con.table("functional_alltypes")
df = t.execute()
expr = ibis.struct(dict(a=t.string_col, b=1, c=t.int_col)).name("s")
assert expr.type() == dt.Struct.from_dict(
dict(a=dt.string, b=dt.int8, c=dt.int32)
)
result = expr.execute()
expected = pd.Series(
(dict(a=a, b=1, c=c) for a, c in zip(df.string_col, df.int_col)),
name="s",
)
tm.assert_series_equal(result, expected)

0 comments on commit a216c18

Please sign in to comment.