fix(io): write NaN values into identity-partitioned float columns - #4030
Merged
Merged
Conversation
_determine_partitions selected the rows of each partition with field == value. NaN never compares equal to itself, so the NaN partition matched zero rows and append() failed with ZeroDivisionError in bin_pack_arrow_table. Select the NaN partition with is_nan, as null is already selected with is_null. Generated-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fokko
approved these changes
Oct 1, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
This is indeed a bug, thanks @breken-ai for fixing this 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Appending a NaN to a table with an identity partition on a
doubleorfloatcolumn fails:_determine_partitionsgroups the rows by partition value, which yields one NaN group, and then selects each group's rows withpc.field(name) == value. NaN never compares equal to itself, so the NaN partition selects zero rows and the empty table reachesbin_pack_arrow_table. Nulls are already handled withis_null(). This PR selects the NaN partition withpc.is_nan()in the same way.After the fix the NaN rows are written to their own partition, and
value is nanreturns them.Are these changes tested?
Yes.
tests/io/test_pyarrow.py:test_determine_partitions_identity_nanchecks that the rows for1.0,NaNandNoneland in their partitions. Onmainit returns{'nan': []}.tests/catalog/test_catalog_behaviors.py:test_append_nan_to_identity_partitioned_tableappends to a real table (memory and SQL catalogs), then checks that a full scan returns all 4 rows andvalue is nanreturns the two NaN rows. Onmainthe append raisesZeroDivisionError.All 4 new tests fail on
mainand pass with the fix.tests/io/test_pyarrow.pyandtests/catalog/test_catalog_behaviors.pypass.prek run --files(ruff, ruff-format, mypy, pydocstyle, codespell) passes. I also checkedfloatcolumns by hand.Are there any user-facing changes?
Yes.
append()/overwrite()now write NaN values into identity-partitioned floating-point columns instead of failing.AI disclosure: this bug was found, fixed and tested by an AI coding agent (Claude) running under the breken-ai account; the red/green runs above are its local results.