Skip to content

Render decimal human strings in plain notation - #4430

Open
AP24110011695 wants to merge 1 commit into
apache:mainfrom
AP24110011695:fix/decimal-human-plain-notation
Open

AP24110011695 wants to merge 1 commit into
apache:mainfrom
AP24110011695:fix/decimal-human-plain-notation

Conversation

@AP24110011695

@AP24110011695 AP24110011695 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What's changed

to_human_string for decimals falls through to plain str(), which renders small magnitudes in scientific notation — a decimal partition value of 0.00000012 surfaces as 1.2E-7 in the partitions inspect table's lower/upper bound columns (_partition_summaries_to_rows renders bounds via field.transform.to_human_string), while #4420 established plain notation for decimal JSON values with the exact same str() hazard.

This registers 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 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-8 renderings) 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.

Are there any user-facing changes?

Yes: decimal lower/upper bounds in the manifests() inspect output now render in plain notation (0.00000012 instead of 1.2E-7), matching the decimal JSON convention from #4420. No API changes.

@rahulsmahadev rahulsmahadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AP24110011695! The four new cases fail on main and pass here, and the plain notation in the manifest bounds looks right.

I'd recommend keeping partition_to_path as it is. It uses the same to_human_string, so 0.00000012 would now be written to x=0.00000012/ instead of x=1.2E-7/. Java writes x=1.2E-7/ (BigDecimal.toString()), so Python would stop matching Java, and one partition could end up with files under both names.

The same symptom remains for truncate. With truncate[10] on decimal(20, 8), this PR still writes x_trunc=1.0E-7/ and shows -2.0E-7 as the manifest lower bound, the same as on main. One option that covers both: keep to_human_string unchanged and do the plain formatting in _partition_summaries_to_rows (inspect.py) for every transform.

Also, the bounds are in inspect.manifests(), not the partitions table, and the template's "Are there any user-facing changes?" section is missing.

Per review: to_human_string must stay unchanged (partition_to_path uses
it, and Java writes x=1.2E-7/ via BigDecimal.toString() — the override
would split partitions across both names). The plain formatting now
lives in _partition_summaries_to_rows (inspect.py) for every transform,
covering manifests() bounds and the truncate case. Also adds the
missing user-facing-changes section to the description.

Signed-off-by: Ayush Kumar Saha <225407166+AP24110011695@users.noreply.github.com>
@AP24110011695
AP24110011695 force-pushed the fix/decimal-human-plain-notation branch from 561e3c0 to 95339d5 Compare November 27, 2026 17:27
@AP24110011695

Copy link
Copy Markdown
Contributor Author

Reworked per your prescription (95339d5) — thanks for the partition_to_path catch, that would have split partitions across both names:

  • to_human_string reverted to main's behavior; the plain formatting now lives in _partition_summaries_to_rows (inspect.py) via a _partition_bound_to_human helper — decimals take the Write decimal default values in plain notation #4420 plain-notation JSON form, every other type keeps to_human_string. Covers both the identity and truncate paths.
  • The tests moved to the inspect harness (test_manifests_render_decimal_bounds_in_plain_notation): the manifest partition-summary bounds assert 0.00000012/100.00000000 plain, no 1.2E-7. Failing-first verified (fails on the pre-rework head).
  • The truncate symptom you showed is covered by the same display-path change.
  • Added the missing "user-facing changes" section to the description.

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.

2 participants