Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datatypes): ensure that array construction supports literals and infers their shape from its inputs #8049

Merged
merged 11 commits into from
Jan 22, 2024

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Jan 20, 2024

We were previously returning ArrayColumn from ibis.array when any inputs were expressions regardless of their shape. This PR renames ArrayColumn -> Array and uses the input arguments shapes to determine the output array shape.

Fixes #8022.

@cpcloud cpcloud added this to the 8.0 milestone Jan 20, 2024
@cpcloud cpcloud added bug Incorrect behavior inside of ibis backends Issues related to all backends datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) sql Backends that generate SQL labels Jan 20, 2024
@cpcloud cpcloud requested a review from kszucs January 20, 2024 13:37
@cpcloud cpcloud force-pushed the fix-array-construction-abstraction branch from 5f094be to 8644eaa Compare January 20, 2024 13:53
ibis/backends/dask/execution/arrays.py Outdated Show resolved Hide resolved
ibis/expr/types/arrays.py Show resolved Hide resolved
ibis/backends/tests/test_array.py Show resolved Hide resolved
if isinstance(v, dd.Series):
return v
else:
return dd.from_pandas(pd.Series([v] * length), npartitions=n_partitions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also worth double checking me here, I'm not familiar with dask, so I was mostly just trying to make this not crash, but I'm not sure if setting n_partitions this way makes sense/is the most performant.

cpcloud and others added 11 commits January 21, 2024 06:24
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.
pd.concat and dd.concat can only handle array-likes. If we are given a
scalar, we need to convert it to the appropriate Series type.
@cpcloud cpcloud force-pushed the fix-array-construction-abstraction branch from 4ccbb15 to b9f9bbe Compare January 21, 2024 11:30
Copy link
Member

@kszucs kszucs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@kszucs kszucs merged commit 899dce1 into ibis-project:main Jan 22, 2024
79 checks passed
@cpcloud cpcloud deleted the fix-array-construction-abstraction branch January 22, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backends Issues related to all backends bug Incorrect behavior inside of ibis datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) sql Backends that generate SQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: ibis.array([ibis.literal(1), ibis.literal(2)]) returns ArrayColumn, not ArrayScalar
3 participants