Skip to content

fix(pandas): preserve native PyArrow dtypes - #2703

Open
maoji-y wants to merge 1 commit into
unionai-oss:mainfrom
maoji-y:bugfix/2702
Open

maoji-y wants to merge 1 commit into
unionai-oss:mainfrom
maoji-y:bugfix/2702

Conversation

@maoji-y

@maoji-y maoji-y commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #2702.

Changes

  • Normalize native pyarrow.DataType instances through pd.ArrowDtype before looking up pandas aliases.
  • Register the parameterized binary constructor only for pyarrow.FixedSizeBinaryType in both modules that register pandas Arrow dtypes.

Backward compatibility

The existing direct-import test now also checks that native Arrow integers and fixed-size binary are resolved correctly. The regression cases cover variable-length binary, fixed-size binary with its byte width, large binary, and timestamp parameters. Supported native Arrow types now resolve the same way as their pd.ArrowDtype inputs. The unregistered month_day_nano_interval type now raises TypeError. The 57-input alias sweep verified this error and matched the baseline for the other 56 inputs.

Verification

  • Windows, Python 3.13.9, pandas 3.1.1, PyArrow 26.0.1. tests/pandas tests/pyarrow passed with 3,292 passed, 20 skipped, and 4 xfailed.
  • Arrow-focused regressions on pandas 2.1.1 with PyArrow 17.0.0 and pandas 2.3.3 with PyArrow 26.0.1 each had 155 passed and 1 skipped. On pandas 3.1.1, all 158 passed.
  • Ruff lint and format, Flynt, pyupgrade, Codespell, and git diff --check passed. Mypy reported the same 165 diagnostics on the base and patch in the local environment.

Implemented and tested with OpenAI Codex assistance.

Normalize native Arrow types before looking up equivalent pandas dtypes. Register the binary parameterized constructor only for fixed-size binary so unregistered Arrow types cannot resolve as binary.

Refs unionai-oss#2702

Signed-off-by: maoji-y <255648417+maoji-y@users.noreply.github.com>
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.02%. Comparing base (fcfc821) to head (8a6a39d).

Files with missing lines Patch % Lines
pandera/engines/pandas_engine.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2703   +/-   ##
=======================================
  Coverage   83.01%   83.02%           
=======================================
  Files         260      260           
  Lines       22951    22945    -6     
=======================================
- Hits        19053    19050    -3     
+ Misses       3898     3895    -3     
Flag Coverage Δ
unit-tests-pandas-Linux-py3.10-pandas2.3.3-pydantic1.10.11 41.82% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.10-pandas2.3.3-pydantic2.12.3 42.00% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.11-pandas2.3.3-pydantic1.10.11 41.82% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.11-pandas2.3.3-pydantic2.12.3 42.00% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.11-pandas3.0.0-pydantic1.10.11 41.83% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.11-pandas3.0.0-pydantic2.12.3 42.00% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.12-pandas2.3.3-pydantic1.10.11 41.81% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.12-pandas2.3.3-pydantic2.12.3 41.99% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.12-pandas3.0.0-pydantic1.10.11 41.82% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-Linux-py3.12-pandas3.0.0-pydantic2.12.3 41.99% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.13-pandas2.3.3-pydantic1.10.11 41.81% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.13-pandas2.3.3-pydantic2.12.3 41.99% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.13-pandas3.0.0-pydantic1.10.11 41.82% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.13-pandas3.0.0-pydantic2.12.3 41.99% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-Linux-py3.14-pandas2.3.3-pydantic2.12.3 41.93% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Linux-py3.14-pandas3.0.0-pydantic2.12.3 41.94% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.10-pandas2.3.3-pydantic1.10.11 41.76% <75.00%> (-0.04%) ⬇️
unit-tests-pandas-Windows-py3.11-pandas2.3.3-pydantic1.10.11 41.76% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.11-pandas2.3.3-pydantic2.12.3 41.93% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.11-pandas3.0.0-pydantic1.10.11 41.76% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.11-pandas3.0.0-pydantic2.12.3 41.94% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-Windows-py3.12-pandas2.3.3-pydantic1.10.11 41.75% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-Windows-py3.12-pandas2.3.3-pydantic2.12.3 41.92% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.12-pandas3.0.0-pydantic1.10.11 41.75% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.12-pandas3.0.0-pydantic2.12.3 41.93% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.13-pandas2.3.3-pydantic1.10.11 41.75% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.13-pandas2.3.3-pydantic2.12.3 41.92% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-Windows-py3.13-pandas3.0.0-pydantic1.10.11 41.75% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.13-pandas3.0.0-pydantic2.12.3 41.93% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-Windows-py3.14-pandas2.3.3-pydantic2.12.3 41.87% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-Windows-py3.14-pandas3.0.0-pydantic2.12.3 41.87% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.10-pandas2.3.3-pydantic1.10.11 41.78% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-macOS-py3.10-pandas2.3.3-pydantic2.12.3 41.95% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.11-pandas2.3.3-pydantic1.10.11 41.78% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-macOS-py3.11-pandas2.3.3-pydantic2.12.3 41.95% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.11-pandas3.0.0-pydantic1.10.11 41.78% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.11-pandas3.0.0-pydantic2.12.3 41.96% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-macOS-py3.12-pandas2.3.3-pydantic1.10.11 41.77% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.12-pandas2.3.3-pydantic2.12.3 41.94% <75.00%> (-0.04%) ⬇️
unit-tests-pandas-macOS-py3.12-pandas3.0.0-pydantic2.12.3 41.95% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.13-pandas2.3.3-pydantic1.10.11 41.77% <75.00%> (+<0.01%) ⬆️
unit-tests-pandas-macOS-py3.13-pandas2.3.3-pydantic2.12.3 41.94% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-macOS-py3.13-pandas3.0.0-pydantic1.10.11 41.77% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-macOS-py3.14-pandas2.3.3-pydantic2.12.3 41.89% <75.00%> (+0.01%) ⬆️
unit-tests-pandas-macOS-py3.14-pandas3.0.0-pydantic2.12.3 41.89% <75.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Linux-py3.10-pandas2.3.3-polars 19.88% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Linux-py3.11-pandas2.3.3-polars 19.88% <0.00%> (+0.01%) ⬆️
unit-tests-pyarrow-Linux-py3.12-pandas2.3.3-polars 19.88% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Linux-py3.13-pandas2.3.3-polars 19.88% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Linux-py3.14-pandas2.3.3-polars 19.72% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Windows-py3.10-pandas2.3.3-polars 19.83% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Windows-py3.11-pandas2.3.3-polars 19.83% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Windows-py3.12-pandas2.3.3-polars 19.83% <0.00%> (+0.01%) ⬆️
unit-tests-pyarrow-Windows-py3.13-pandas2.3.3-polars 19.83% <0.00%> (+<0.01%) ⬆️
unit-tests-pyarrow-Windows-py3.14-pandas2.3.3-polars 19.67% <0.00%> (-1.71%) ⬇️
unit-tests-pyarrow-macOS-py3.10-pandas2.3.3-polars 19.83% <0.00%> (-0.27%) ⬇️
unit-tests-pyarrow-macOS-py3.11-pandas2.3.3-polars 19.83% <0.00%> (-1.26%) ⬇️
unit-tests-pyarrow-macOS-py3.12-pandas2.3.3-polars 19.83% <0.00%> (-1.69%) ⬇️
unit-tests-pyarrow-macOS-py3.13-pandas2.3.3-polars 19.83% <0.00%> (-1.29%) ⬇️
unit-tests-pyarrow-macOS-py3.14-pandas2.3.3-polars 19.67% <0.00%> (-1.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native PyArrow dtypes resolve as unrelated pandas types

1 participant