Repository navigation
Render decimal human strings in plain notation - #4430
Open
AP24110011695 wants to merge 2 commits into
Open
AP24110011695 wants to merge 2 commits into
AP24110011695 wants to merge 2 commits into
Conversation
to_human_string for decimals falls through to str(), which renders small magnitudes in scientific notation — a decimal partition value of 0.00000012 shows up as 1.2E-7 in the partitions inspect table's lower and upper bound columns, while apache#4420 established plain notation for decimal JSON values. Register a Decimal override on the human-string helper using the same rule as the JSON path (plain f-notation when the exponent is zero or negative, str otherwise, which keeps the negative-scale scientific convention). The four new parametrize cases fail on main and pass with the override; the 17 pyarrow-parametrized failures in this file are the pristine-main environment baseline, unchanged. Refs apache#4420. Signed-off-by: Ayush Kumar Saha <225407166+AP24110011695@users.noreply.github.com>
Decimal.as_tuple's exponent element is the string 'n'/'N'/'F' for NaN and Infinity specials, so mypy rejects comparing it against int directly. Restore the isinstance narrowing the conversions.py counterpart uses (the one-line compression dropped it). Signed-off-by: Ayush Kumar Saha <225407166+AP24110011695@users.noreply.github.com>
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.
What's changed
to_human_stringfor decimals falls through to plainstr(), which renders small magnitudes in scientific notation — a decimal partition value of0.00000012surfaces as1.2E-7in the partitions inspect table's lower/upper bound columns (_partition_summaries_to_rowsrenders bounds viafield.transform.to_human_string), while #4420 established plain notation for decimal JSON values with the exact samestr()hazard.This registers a
Decimaloverride on the human-string helper using the same rule as the JSON path: plain f-notation when the exponent is zero or negative,str()otherwise (which keeps the negative-scale scientific convention the conversions docstring documents). The human-string helper is what the identity transform and the inspect path route through.Test
Four new parametrize cases in
test_identity_human_string(small magnitude, zero, negative small magnitude, and a 38,18 case) — verified failing-first on main (1.2E-7/0E-8renderings) and passing with the override. The 17 pyarrow-parametrized failures in this file are the pristine-main environment baseline on this machine (verified by stash A/B: identical set, unchanged by this PR).AI disclosure: drafted with AI assistance, verified locally by running the failing-first cycle and an end-to-end write +
inspect.partitions()probe.