From 86c866950529ae0277db18369c830050b87efcc6 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Fri, 29 Sep 2023 11:26:03 -0500 Subject: [PATCH] feat(api): support deferred arguments to `ibis.map` --- ibis/expr/types/maps.py | 2 ++ ibis/tests/expr/test_value_exprs.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ibis/expr/types/maps.py b/ibis/expr/types/maps.py index 990ca5626ab0..6284878ae6ab 100644 --- a/ibis/expr/types/maps.py +++ b/ibis/expr/types/maps.py @@ -7,6 +7,7 @@ import ibis.expr.operations as ops from ibis.expr.types.arrays import ArrayColumn from ibis.expr.types.generic import Column, Scalar, Value +from ibis.expr.deferred import deferrable if TYPE_CHECKING: import ibis.expr.types as ir @@ -425,6 +426,7 @@ def __getitem__(self, key: ir.Value) -> ir.Column: @public +@deferrable def map( keys: Iterable[Any] | Mapping[Any, Any] | ArrayColumn, values: Iterable[Any] | ArrayColumn | None = None, diff --git a/ibis/tests/expr/test_value_exprs.py b/ibis/tests/expr/test_value_exprs.py index a5d5254f5da3..91ce9139f39a 100644 --- a/ibis/tests/expr/test_value_exprs.py +++ b/ibis/tests/expr/test_value_exprs.py @@ -1584,7 +1584,13 @@ def test_deferred_function_call(func, expected_type): @pytest.mark.parametrize( - "case", [param(lambda: (ibis.array([1, _]), ibis.array([1, 2])), id="array")] + "case", + [ + param(lambda: (ibis.array([1, _]), ibis.array([1, 2])), id="array"), + param( + lambda: (ibis.map({"x": 1, "y": _}), ibis.map({"x": 1, "y": 2})), id="map" + ), + ], ) def test_deferred_nested_types(case): expr, sol = case()