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:
SELECT format_string('%(,.2f', CAST(-1234.50 AS DECIMAL(10, 2)));
Current result:
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:
For %(,15.2f, the result should be padded to the requested width:
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.
Describe the bug
The Spark-compatible
format_stringfunction does not honor the(flag when formatting negativeDecimalvalues. 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:
Current result:
A fixed-width format such as
%(,15.2fsimilarly produces a minus sign instead of parentheses.Expected behavior
The result should match Spark/Java formatting semantics:
For
%(,15.2f, the result should be padded to the requested width:Additional context
ConversionSpecifier::format_decimalreads the sign but does not applynegative_in_parentheses. Supporting the flag also requires accounting for the closing parenthesis when applying width, left alignment, and zero padding.