Repository navigation
fix(spec): reject non-finite partition values when writing DataFile JSON - #3529
Open
ninglinLiu wants to merge 2 commits into
Open
ninglinLiu wants to merge 2 commits into
ninglinLiu wants to merge 2 commits into
Conversation
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.
Which issue does this PR close?
#3476 fixed the first half of the issue (valid floats such as
123.456being rejected on read). This PR covers the second half: non-finite partition values silently becomingnull.What changes are included in this PR?
JSON has no representation for
NaNor±Infinity, andserde_jsonwrites them asnull. Soserialize_data_file_to_jsonturned a non-finite float or double partition value intonull, anddeserialize_data_file_from_jsonthen read it back as a null partition value, with no error anywhere. That is how the incorrect metadata in the issue got committed.serialize_data_file_to_jsonnow checks the partition tuple before serializing and returns aDataInvaliderror naming the partition field when a float or double value is not finite, instead of writingnull. Finite values are unchanged. The Avro manifest path is not touched, since Avro stores these values exactly.Are these changes tested?
Yes.
test_data_file_to_json_rejects_non_finite_partition_valuesround-trips a data file with finite float and double partition values, and checks thatNaN,+Infinity(float) andNaN,-Infinity(double) are rejected with an error naming the field. The test fails onmainand passes with the change.cargo test -p iceberg --lib spec::manifestandcargo clippy -p iceberg --all-targets -- -D warningspass.This PR was prepared with AI assistance and reviewed/tested by the author.