andygrove opened a new issue, #423:
URL: https://github.com/apache/datafusion-spark/issues/423
### Describe the bug
`format_string` with the `#` flag on `%e` puts the decimal point after the
exponent. `format_string('%#.0e', 5.0)` returns `5e+00.`, where Spark returns
`5.e+00`.
The `alt_form` branch appends `.` to the whole formatted number when it has
no decimal point
([format_string.rs#L1796](https://github.com/apache/datafusion-spark/blob/ab9d308e4ee504dbd3a9731abfc3519f937c86d1/crates/spark/src/function/string/format_string.rs#L1796)).
For `%e` the number already ends in the exponent at that point, so the `.`
lands after it. It should go after the mantissa.
### To Reproduce
```sql
SELECT format_string('%#.0e', CAST(5.0 AS DOUBLE));
```
datafusion-spark returns `5e+00.`.
### Expected behavior
As in Spark (Java `String.format`):
```
5.e+00
```
`%#.0e` of `0.0` gives `0.e+00` in Spark. `%#e` with the default precision
already has a decimal point, so it is not affected.
### Spark versions
Checked on PySpark 4.2.0 and 3.5.9, which give the same result.
### datafusion-spark version
main at ab9d308
### Additional context
Found while reviewing #416, which fixes zero for `%e` and `%g`. This bug is
separate from that one.
--
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]