Skip to content

Commit

Permalink
refactor(arrays): remove type argument from ibis.array function
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `type` argument is removed from `ibis.array`. Ibis will attempt to infer the type of your input as it did before. If you need a specific type, cast the return value of `ibis.array` to a specific array type.
  • Loading branch information
cpcloud committed Jan 20, 2024
1 parent bae6b21 commit 8644eaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def test_unnest_default_name(backend):
array_types = backend.array_types
df = array_types.execute()
expr = (
array_types.x.cast("!array<int64>") + ibis.array([1], type="!array<int64>")
array_types.x.cast("!array<int64>") + ibis.array([1]).cast("!array<int64>")
).unnest()
assert expr.get_name().startswith("ArrayConcat(")

Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def test_format_literal(literal, typ, output):


def test_format_dummy_table(snapshot):
t = ops.DummyTable([ibis.array([1], type="array<int8>").name("foo")]).to_expr()
t = ops.DummyTable([ibis.array([1]).cast("array<int8>").name("foo")]).to_expr()

result = fmt(t)
assert "DummyTable" in result
Expand Down
11 changes: 2 additions & 9 deletions ibis/expr/types/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,22 +1017,17 @@ def __getitem__(self, index: int | ir.IntegerValue | slice) -> ir.Column:

@public
@deferrable
def array(values: Iterable[V], type: str | dt.DataType | None = None) -> ArrayValue:
def array(values: Iterable[V]) -> ArrayValue:
"""Create an array expression.
Parameters
----------
values
An iterable of Ibis expressions or a list of Python literals
type
An instance of `ibis.expr.datatypes.DataType` or a string indicating
the Ibis type of `value`.
Returns
-------
ArrayValue
An array column (if the inputs are column expressions), or an array
scalar (if the inputs are Python literals)
Examples
--------
Expand Down Expand Up @@ -1070,6 +1065,4 @@ def array(values: Iterable[V], type: str | dt.DataType | None = None) -> ArrayVa
│ [3, 42] │
└──────────────────────┘
"""
if type is None:
return ops.Array(tuple(values)).to_expr()
return literal(list(values), type=type)
return ops.Array(tuple(values)).to_expr()

0 comments on commit 8644eaa

Please sign in to comment.