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

[Python] pyarrow.scalar doesn't accept nested pyarrow values #18987

Open
asfimport opened this issue Dec 9, 2021 · 1 comment
Open

[Python] pyarrow.scalar doesn't accept nested pyarrow values #18987

asfimport opened this issue Dec 9, 2021 · 1 comment

Comments

@asfimport
Copy link
Collaborator

Easiest explained in code:

import pyarrow as pa

t1 = pa.struct([('x', pa.int64())])
t2 = pa.struct([('y', t1)])

t1_py = {'x', 0}
t1_pa = pa.scalar(t1_py, type=t1)

t2_py = {'y': {'x': 0}}
t2_pa = pa.scalar(t2_py, type=t2)  # works

t2_mixed = {'y': t1_pa}
t2_pa_mix = pa.scalar(t2_mixed, type=t2)  # fails
assert t2_pa_mix == t2_pa

Is there some other way to construct the pyarrow struct value corresponding to t2_pa given t1_pa directly, without going through python first (i.e. constructing t1_py)?

Reporter: Vlad Firoiu

Note: This issue was originally created as ARROW-15050. Please see the migration documentation for further details.

@asfimport
Copy link
Collaborator Author

Joris Van den Bossche / @jorisvandenbossche:
[~vladfi] thanks for the report. I think this essentially comes back to ARROW-5295 (which is a similar issue but for arrays, but both arrays and scalar functions for the python->arrow conversion use the same code path I think).

The current generic python->arrow conversion layer cannot handle our own scalars, but only Python scalars (+ some numpy and pandas ones)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant