Skip to content

Fix incorrect partition length metadata for Partitions expression - #12290

Draft
abslock128w wants to merge 19 commits into
dask:mainfrom
abslock128w:Invalidate-partition-length-metadata-for-Partitions-expr
Draft

abslock128w wants to merge 19 commits into
dask:mainfrom
abslock128w:Invalidate-partition-length-metadata-for-Partitions-expr

Conversation

@abslock128w

@abslock128w abslock128w commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Partition slicing via df.partitions[...] could incorrectly reuse concrete
length metadata from the parent expression, leading to mismatches between
metadata length and computed results and causing flaky test failures....
that partition length metadata is only reported when it can
be inferred correctly. I also added a regression test to verify that any concrete
length reported for a partition always matches the computed length.
please do have look and lmk if this work!!

On minimal pandas versions, concatenation of categorical data does not guarantee stable ordering of values, even when categories and dtypes match. The test was asserting positional equality for categorical Series, which is stronger than the guarantees provided by pandas and leads to frequent failures in mindeps-optional.
Removed redundant checks for categorical values in concat tests.
Add a test to verify that the length of partitions matches the computed length.
@github-actions

github-actions Bot commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

     21 files  ± 0       21 suites  ±0   5h 8m 42s ⏱️ +38s
 18 285 tests + 1   17 010 ✅ + 1   1 274 💤 ±0  1 ❌ ±0 
294 802 runs  +15  252 459 ✅ +13  42 341 💤 +1  2 ❌ +1 

For more details on these failures, see this check.

Results for commit c1d0d02. ± Comparison against base commit 6ac1553.

♻️ This comment has been updated with latest results.

@crusaderky crusaderky 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.

This PR fundamentally misunderstands the issue.

I did not run the code. However, either of these two statements is true:

  • this PR does nothing (the new _length method is never executed); in the unit test, len(part) still continues computing the concrete result (which has always worked and is tested under normal conditions)
  • OR this test fundamentally breaks len(Dataframe), so that in one specific niche use case it stops computing and instead returns NaN, whereas in many other cases (e.g. after a filter operation) it continues triggering a partial computation as before - which is typically desirable, since predicate pushdown allows skipping most of the work that used to be implied in the past (such as loading the full data to disk).

In both cases, the unit test passes before and after the change, which makes it not fit for purpose.

This PR also does not answer the question as of why, in most runs, the original unit test passes. This PR implies that the issue is deterministic, which clearly isn't.

@abslock128w

Copy link
Copy Markdown
Contributor Author

Hmm makes sense
Will dig deeper into this...
Ill revert the current changes and try to find the actual root cause before working on the fix
Thank you for the feedback again!!!

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.

Flaky test_collection.py::test_len

2 participants