-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[C++] Cast between fixed size list type and variable size list #20086
Comments
Eduardo Ponce / @edponce: >>> fixed_size = pa.scalar([1, 2], type=pa.list_(pa.int64(), 2))
>>> fixed_size.cast(pa.list_(pa.int64()))
...
pyarrow.lib.ArrowNotImplementedError: casting scalars of type fixed_size_list<item: int64>[2] to type list<item: int64> |
Eduardo Ponce / @edponce: # Works with Array
>>> fixed_size = pa.array([[1, 2]], type=pa.list_(pa.int64(), 2))
>>> fixed_size.cast(pa.list_(pa.int64(), 2))
<pyarrow.lib.FixedSizeListArray object at 0x1059e9f00>
[[1, 2]]
# Does not works with Scalar
>>> fixed_size = pa.scalar([1, 2], type=pa.list_(pa.int64(), 2))
>>> fixed_size.cast(pa.list_(pa.int64(), 2))
pyarrow.lib.ArrowNotImplementedError: casting scalars of type fixed_size_list<item: int64>[2] to type fixed_size_list<item: int64>[2] |
Jabari Booker / @JabariBooker:
#For Lists
>>> arrow_list = pa.scalar([1, 2])
>>> arrow_list.cast(pa.list_(pa.int64()))
pyarrow.lib.ArrowNotImplementedError: casting scalars of type list<item: int64> to type list<item: int64>
#For LargeLists
>>> arrow_list = pa.scalar([1, 2], pa.large_list(pa.int64()))
>>> arrow_list.cast(pa.large_list(pa.int64()))
pyarrow.lib.ArrowNotImplementedError: casting scalars of type large_list<item: int64> to type large_list<item: int64>
|
Todd Farmer / @toddfarmer: |
Jabari Booker / @JabariBooker: |
Apache Arrow JIRA Bot: |
### Rationale for this change These list types should be able to cast to each other. In our code base, we find users might naively make an list array (for example, with `pa.Table.from_pylist()`) and want it automatically casted to a tensor array (which is based on a fixed size list). ### What changes are included in this PR? Adds casts from FSL -> (Large)List and (Large)List -> FSL. ### Are these changes tested? The kernels are tested. ### Are there any user-facing changes? Just a new kernel. * Closes: #20086 Authored-by: Will Jones <willjones127@gmail.com> Signed-off-by: Will Jones <willjones127@gmail.com>
…apache#37292) ### Rationale for this change These list types should be able to cast to each other. In our code base, we find users might naively make an list array (for example, with `pa.Table.from_pylist()`) and want it automatically casted to a tensor array (which is based on a fixed size list). ### What changes are included in this PR? Adds casts from FSL -> (Large)List and (Large)List -> FSL. ### Are these changes tested? The kernels are tested. ### Are there any user-facing changes? Just a new kernel. * Closes: apache#20086 Authored-by: Will Jones <willjones127@gmail.com> Signed-off-by: Will Jones <willjones127@gmail.com>
Casting from fixed size list to variable size list could be possible, I think, but currently doesn't work:
And in principle, a cast the other way around could also be possible if it is checked that each list has the correct length.
Reporter: Joris Van den Bossche / @jorisvandenbossche
PRs and other links:
Note: This issue was originally created as ARROW-15455. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: