Repository navigation
Conversation
Parquet statistics do not track NaN values, so data files written by PyIceberg never carried nan_value_counts. The strict metrics evaluator reads a missing NaN count as "no NaN values", so a delete such as `value < 5.0` dropped whole files and lost NaN rows that do not match the filter. Count NaN values of float and double columns while writing, as the Java Parquet writers do.
This branch has not been deployed
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.
Closes #4130
Rationale for this change
Parquet statistics do not track NaN values, so data files written by PyIceberg never carry
nan_value_counts. The strict metrics evaluator reads a missing NaN count as "no NaN values" (as Java does, since Java's Parquet writers always record these counts). That meansTable.delete("x < 5.0")drops a file containing[1.0, NaN]as a whole, so the NaN row is lost even though it does not match the filter.This change counts NaN values of float and double columns in
ParquetFormatWriter.write, including nested struct fields, list elements and map values. It skips columns whose metrics mode isnone, matching how the Java writers populatenan_value_counts. The counts are passed todata_file_statistics_from_parquet_metadatathrough a new optional argument. Files without float or double columns do no extra work.Files that are already written keep their missing counts. Files registered through
add_filesare unchanged, since that path only has the Parquet footer.Are these changes tested?
Yes.
tests/io/test_format_writers.py: NaN counts for top-level float and double columns, a struct field, list elements and map values across multiplewrite()calls, zero counts for columns without NaN, and no count for a column with metrics modenone.tests/catalog/test_catalog_behaviors.py:delete("value < 5.0")on a file with[1.0, NaN]keeps the NaN row (fails on main for the memory and sql catalogs).tests/integration/test_writes/test_writes.py::test_merge_manifests: updated the expectednan_value_countsfrom[]to[(6, 0), (7, 0)]for the float and double columns.make testandmake lintpass locally.Are there any user-facing changes?
Data files written by PyIceberg now include
nan_value_countsfor float and double columns. This fixes the delete above and lets scans prune on NaN counts.