wangzhigang1999 opened a new issue, #23717:
URL: https://github.com/apache/datafusion/issues/23717
### Describe the bug
The Spark-compatible `format_string` function does not honor the `(` flag
when formatting negative `Decimal` values. Instead of enclosing the magnitude
in parentheses, the decimal formatting path always emits a minus sign.
The floating-point formatting path already handles this flag correctly, so
decimal and floating-point values currently produce inconsistent results.
### To Reproduce
Format a negative decimal using the grouping separator and parentheses flags:
```sql
SELECT format_string('%(,.2f', CAST(-1234.50 AS DECIMAL(10, 2)));
```
Current result:
```text
-1,234.50
```
A fixed-width format such as `%(,15.2f` similarly produces a minus sign
instead of parentheses.
### Expected behavior
The result should match Spark/Java formatting semantics:
```text
(1,234.50)
```
For `%(,15.2f`, the result should be padded to the requested width:
```text
(1,234.50)
```
### Additional context
`ConversionSpecifier::format_decimal` reads the sign but does not apply
`negative_in_parentheses`. Supporting the flag also requires accounting for the
closing parenthesis when applying width, left alignment, and zero padding.
--
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]