vaidik787 opened a new pull request, #427:
URL: https://github.com/apache/datafusion-spark/pull/427
## Which issue does this PR close?
- Closes #423.
## Rationale for this change
`format_string('%#.0e', 5.0)` returns `5e+00.`, where Spark (Java
`String.format`) returns `5.e+00`. The `#` flag adds a decimal point to the
whole formatted number when it has none. For `%e` the number already ends in
the exponent at that point, so the `.` lands after it.
## What changes are included in this PR?
In the scientific-notation branch of the float formatter, the decimal point
for the `#` flag is now added to the mantissa, before the exponent is appended.
Fixed-point output and `%e` with a precision that already prints a decimal
point are not affected.
## Are these changes tested?
Yes. Three new records in `string/format_string.slt`: `%#.0e` of `5.0` gives
`5.e+00`, `%#.0E` of `12345.0` gives `1.E+04`, and `%#.2e` of `5.0` is
unchanged at `5.00e+00`. `cargo test -p datafusion-spark-sqllogictest` passes
(518 of 518 runs), and `cargo fmt` and `cargo clippy --all-targets -- -D
warnings` are clean.
The expected values come from the Spark results reported in #423 (PySpark
4.2.0 and 3.5.9); I did not run PySpark myself. The new records carry the same
`xfail spark` note as the neighbouring `%#.0f` records, because Spark types the
literal as DECIMAL (#97).
## Are there any user-facing changes?
`format_string` with `%#e` or `%#E` and no fractional digits now returns
Spark's result. No API change.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01LjXwp6RG3FDtC4t3PqLCQs
--
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]