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] Mappings that implement __arrow_c_schema__ never have their method invoked #43388

Closed
cpcloud opened this issue Jul 23, 2024 · 3 comments

Comments

@cpcloud
Copy link
Contributor

cpcloud commented Jul 23, 2024

Describe the bug, including details regarding any error messages, version, and platform.

The implementation of pyarrow.schema doesn't allow objects that are Mappings to take advantage of __arrow_c_schema__ because Mapping is checked before __arrow_c_schema__ is checked.

This seems like a bug considering that custom schema objects naturally fit into the Mapping concept.

Would it make sense to swap the order here and first check for __arrow_c_schema__ and then check whether an object is a mapping?

Component(s)

Python

@ianmcook ianmcook changed the title Mappings that implement __arrow_c_schema__ never have their method invoked [Python] Mappings that implement __arrow_c_schema__ never have their method invoked Jul 25, 2024
@jorisvandenbossche
Copy link
Member

Good point, thanks for the issue!
I don't think there was a specific reason for this order in the code (added in #37797, cc @wjones127). Will do a PR to switch the order.

@jorisvandenbossche jorisvandenbossche self-assigned this Jul 30, 2024
jorisvandenbossche added a commit to jorisvandenbossche/arrow that referenced this issue Jul 30, 2024
@jorisvandenbossche
Copy link
Member

-> #43486

jorisvandenbossche added a commit that referenced this issue Aug 7, 2024
…a(..) (#43486)

### Rationale for this change

When converting an object to a pyarrow.Schema with `pa.schema(..)`, first check the capsule interface before checking for mappings. This allows other schema-like objects that expose the capsule interface to also be mappings.

### Are these changes tested?
Yes

* GitHub Issue: #43388

Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@jorisvandenbossche jorisvandenbossche added this to the 18.0.0 milestone Aug 7, 2024
@jorisvandenbossche
Copy link
Member

Issue resolved by pull request 43486
#43486

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

2 participants