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

[C++] Zero-case union can't be imported via C Data Interface #14855

Closed
lidavidm opened this issue Dec 6, 2022 · 3 comments · Fixed by #14857
Closed

[C++] Zero-case union can't be imported via C Data Interface #14855

lidavidm opened this issue Dec 6, 2022 · 3 comments · Fixed by #14857
Assignees
Milestone

Comments

@lidavidm
Copy link
Member

lidavidm commented Dec 6, 2022

The zero-case union is apparently not supported by Arrow C++'s C Data interface. I get:

'arrow_type' failed with Invalid: Invalid or unsupported format string: '+us:'

Reproducer for Python:

import pyarrow as pa
from pyarrow.cffi import ffi
empty_union = pa.sparse_union([])
ptr = ffi.new("struct ArrowSchema*")
empty_union._export_to_c(int(ffi.cast("uintptr_t", ptr)))
pa.DataType._import_from_c(int(ffi.cast("uintptr_t", ptr)))
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
#   File "pyarrow/types.pxi", line 248, in pyarrow.lib.DataType._import_from_c
#   File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
#   File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
# pyarrow.lib.ArrowInvalid: Invalid or unsupported format string: '+us:'

Originally posted by @paleolimbot in apache/arrow-nanoarrow#81 (comment)

Component(s)

C++

@westonpace
Copy link
Member

For my own education, is there a practical use for a zero-case union?

@lidavidm
Copy link
Member Author

lidavidm commented Dec 7, 2022

I can't think of one off the top of my head, this is more about just making sure everything roundtrips properly.

@paleolimbot
Copy link
Member

I think the only way it could be even be valid is if it was length zero?

lidavidm added a commit to lidavidm/arrow that referenced this issue Dec 12, 2022
@pitrou pitrou added this to the 11.0.0 milestone Dec 12, 2022
pitrou pushed a commit that referenced this issue Dec 12, 2022
Closes #14855.
* Closes: #14855

Authored-by: David Li <li.davidm96@gmail.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants