Uh oh!
There was an error while loading. Please reload this page.
GH-39914: [pyarrow] Reorder to_pandas extension dtype mapping - #44720
Conversation
Addresses pandas-dev/pandas#53011 `types_mapper` always had highest priority as it overrode what was set before. However, switching the logical ordering, it means that we don't need to call `_pandas_api.pandas_dtype(dtype)` when using the pyarrow backend. Resolving the issue of complex `dtype` with `list` or `struct`
❌ GitHub issue #53011 could not be retrieved. |
jorisvandenbossche
commented
Nov 14, 2024
And because you added a |
Uh oh!
There was an error while loading. Please reload this page.
bretttully
commented
Nov 14, 2024
Yes, exactly. Priority remains the same, but functions are skipped if the field already has a type, meaning that the code causing the error is no longer called if types_mapper is provided. |
jorisvandenbossche
commented
Nov 14, 2024
The |
jorisvandenbossche
left a comment
There was a problem hiding this comment.
Looks good!
I triggered CI again
Uh oh!
There was an error while loading. Please reload this page.
bretttully
commented
Nov 20, 2024
Thanks @jorisvandenbossche -- is the process that I can merge this following approval, or is that done by a core maintainer? |
raulcd
commented
Nov 20, 2024
A committer will merge, probably @jorisvandenbossche in this specific case, once everything is running and addressed. I've triggered CI for the latest changes. |
Uh oh!
There was an error while loading. Please reload this page.
jorisvandenbossche
commented
Nov 20, 2024
@github-actions crossbow submit -g python |
Revision: e3b9892 Submitted crossbow builds: ursacomputing/crossbow @ actions-e01b93275b |
jorisvandenbossche
commented
Nov 21, 2024
@raulcd it seems something is going wrong with the minimal test builds (eg example-python-minimal-build-fedora-conda). The logs indicate "Successfully installed pyarrow-0.1.dev16896+ge3b9892", which then messes up pandas detection of the pyarrow version (for the pyarrow integration in pandas, pandas checks if pyarrow is recent enough and otherwise errors), giving some test failures. (but also not entirely sure how this PR causes this issue, since I don't see the nightlies fail for the minimal builds at the moment) |
jorisvandenbossche
commented
Nov 21, 2024
(the other failures are the known nightly dlpack failures) |
raulcd
commented
Nov 21, 2024
From the git checkout I see is pulling from the remote on |
raulcd
commented
Nov 21, 2024
I've opened an issue because we should find a way to not fail if the dev tag is not present: |
jorisvandenbossche
commented
Nov 21, 2024
Thanks for investigating that! So then to resolve this here, @bretttully should fetch the upstream tags and push that to his fork? Something like (assuming upstream is apache/arrow and origin is bretttully/arrow) |
bretttully
commented
Nov 21, 2024
I have merged |
raulcd
commented
Nov 21, 2024
@github-actions crossbow submit example-python-minimal-build-* |
Revision: 685167f Submitted crossbow builds: ursacomputing/crossbow @ actions-524e782c26
|
bretttully
commented
Nov 24, 2024
Is there anything else for me to do here? |
raulcd
commented
Nov 25, 2024
I don't think so. I am not comfortable with this area of our codebase so I'll let @jorisvandenbossche merge once he's happy about it, but as he already approved, he might do that soon. |
jorisvandenbossche
commented
Nov 27, 2024
No, just me getting back to merge it! |
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 8548c22. There were 132 benchmark results with an error:
There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them. |
bretttully
commented
Nov 27, 2024
🚀 Thanks for all your help here @jorisvandenbossche! |
Rationale for this change
This is a long standing pandas ticket with some fairly horrible workarounds, where complex arrow types do not serialise well to pandas as the pandas metadata string is not parseable. However,
types_mapperalways had highest priority as it overrode what was set before.What changes are included in this PR?
By switching the logical ordering, it means that we don't need to call
_pandas_api.pandas_dtype(dtype)when using the pyarrow backend, thus resolving the issue of complexdtypewithlistorstruct. It will likely still fail if the numpy backend is used, but at least this gives a working solution rather than an inability to load files at all.Are these changes tested?
Existing tests should stay unchanged and a new test for the complex type has been added
Are there any user-facing changes?
This PR contains a "Critical Fix".
This makes
pd.read_parquet(..., dtype_backend="pyarrow")work with complex data types where the metadata added by pyarrow duringpd.to_parquetis not serialisable and currently throwing an exception. This issue currently prevents the use of pyarrow as the default backend for pandas.