compiler-segfault opened a new pull request, #416:
URL: https://github.com/apache/datafusion-spark/pull/416
Fixes #403.
`%e` and `%g` of `0.0` computed the exponent as `abs.log10().floor() as
i32`. `log10(0)` is `-inf`, so the cast saturated to `i32::MIN`: `%g` then
panicked with `attempt to subtract with overflow` on `precision - 1 -
exponent`, and `%e` divided by `10^i32::MIN` and printed `NaNe-2147483648`.
Zero now uses exponent 0, which is what `java.util.Formatter` does, so
`format_string('%e', 0.0::DOUBLE)` returns `0.000000e+00` and
`format_string('%g', 0.0::DOUBLE)` returns `0.00000`. The recomputation after
rounding in the `%g` branch got the same treatment, because it also derived the
exponent from `log10`.
Verification:
- `cargo test -p datafusion-spark-sqllogictest`: 518 of 518 test runs
passed; the two new cases in `string/format_string.slt` fail on `main`.
- `cargo test -p datafusion-spark`: 603 passed.
- `cargo fmt --all -- --check` and `cargo clippy --all-targets
--all-features -- -D warnings` are clean.
The text above was drafted with an AI assistant; I ran the tests myself.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]