Skip to content

Require pandera>=0.27 and un-xfail the dask series test - #1770

Open
Thanatos9404 wants to merge 3 commits into
apache:mainfrom
Thanatos9404:fix/1279-require-pandera-0-23
Open

Thanatos9404 wants to merge 3 commits into
apache:mainfrom
Thanatos9404:fix/1279-require-pandera-0-23

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 18, 2026 •

Copy link
Copy Markdown

Fixes #1279

The KeyError: 'dask' comes from pandera rather than import order in Hamilton. Since dask 2025.1, dask-expr ships inside dask, so a dask series is a dask.dataframe.dask_expr._collection.Series, and pandera before 0.23 maps only the old top-level dask_expr module to its dask backend (fixed in unionai-oss/pandera#1898). DataFrameSchema.validate maps over the partitions before that lookup, which is why only the series test broke.

Changes

  • pandera[pandas]>=0.27 for the pandera extra and the docs group, and pandera[dask,pandas]>=0.27 in the test group and tests/integrations/pandera/requirements.txt. 0.27 is the first release that works with everything main allows: 0.23 to 0.25 fail to import pandera.typing.polars with polars 2, and 0.26.x fails pandas checks on Python 3.14 (0.27.0 added 3.14 support). The pandas extra keeps pandera's own pandas and numpy floors.
  • A CI step that reruns tests/integrations with pandera 0.27.0 after the run with the newest pandera, so the floor stays tested.
  • Removed the xfail from test_pandera_decorator_dask_series and added a test where only the last of two partitions of a dask series breaks the schema.

How I tested this

tests/integrations with pandera 0.27.0, dask 2026.8.0, pandas 3.1.1 and polars 2.1.0: 15 passed on Python 3.11, 3.12, 3.13 and 3.14. With 0.26.1 on 3.14, 3 tests fail. I couldn't run 3.15 locally, so that one rests on CI. prek run --files passes on the changed files.

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality. (No user-facing change beyond the dependency floor.)

Validating a dask series against a pandera SeriesSchema raised
KeyError: 'dask' with pandera<0.23 and dask>=2025.1. Since dask-expr
moved into dask, dask series live in `dask.dataframe.dask_expr`, and
pandera before 0.23 only maps the old top-level `dask_expr` module name
to its dask backend. SeriesSchema.validate looks the type up first, so
the series path failed; DataFrameSchema maps over the partitions before
any lookup, which is why dask dataframes were unaffected. The error
also happens without Hamilton. pandera fixed the lookup in 0.23.0
(unionai-oss/pandera#1898).

Set pandera>=0.23 for the pandera extra, the test and docs dependency
groups, and the pandera integration test requirements. Remove the xfail
from test_pandera_decorator_dask_series and add a test where only the
last partition of a dask series breaks the schema.

Fixes apache#1279
@Dev-iL
Dev-iL requested a review from skrawcz November 3, 2026 08:22

@Dev-iL Dev-iL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Pandera 0.23 is over 1.5 years old, so users are unlikely to be negatively impacted.

@skrawcz skrawcz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted preliminary review — findings must be fixed or technically refuted before human review.

The diagnosis of the Dask Series failure is correct, and the xfail removal plus last-partition regression test are focused. The proposed pandera>=0.23 floor is incomplete against current main, though. Current resolution permits Polars 2.1, and Pandera 0.23 through 0.25 crash while importing hamilton.plugins.h_pandera because their Polars engine calls pl.Categorical(ordering=...), which Polars 2 removed.

This was reproduced at the PR head: Pandera 0.23 + Dask 2025.1 + Polars 1.44 passes the integration file, while the same Pandera/Dask with Polars 2.1 fails during collection. In a sequential import check, 0.23–0.25 failed and 0.26 was the first tested Pandera release that imported with Polars 2.

Please raise or condition the floor to cover every allowed dependency combination and add a lower-bound compatibility check rather than validating only latest Pandera, or provide evidence that Polars 2 cannot occur in the supported environment.

pandera 0.23 to 0.25 fail to import pandera.typing.polars with polars 2
(pl.Categorical no longer takes `ordering`), and 0.26 fails pandas checks
on Python 3.14. 0.27.0 is the first release that works with both, so it
is the new floor for the pandera extra, the test and docs groups and the
integration requirements. The pandas extra keeps pandera's own pandas and
numpy floors, which moved out of its base requirements in 0.24.

A new CI step reruns tests/integrations with pandera 0.27.0 after the
run with the newest pandera, so the floor stays tested.
@Thanatos9404 Thanatos9404 changed the title Require pandera>=0.23 and un-xfail the dask series test Require pandera>=0.27 and un-xfail the dask series test Nov 9, 2026
@Thanatos9404

Copy link
Copy Markdown
Author

Thanks, you're right. I merged main and raised every pin to 0.27: 0.23 to 0.25 fail to import pandera.typing.polars with polars 2, and 0.26.0 and 0.26.1 fail pandas checks on Python 3.14, while 0.27.0 passes tests/integrations on 3.11 to 3.14 with polars 2.1 and pandas 3.1. The pandas extra keeps pandera's own pandas and numpy floors, and a new CI step reruns the integration tests with pandera 0.27.0, so the floor itself stays tested.

@Dev-iL
Dev-iL requested a review from skrawcz November 9, 2026 18:03

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.

data quality dask series schema issue

3 participants