kosiew commented on code in PR #24480:
URL: https://github.com/apache/datafusion/pull/24480#discussion_r3810671967
##########
datafusion/sqllogictest/test_files/spark/string/format_string.slt:
##########
@@ -2064,6 +2064,83 @@ SELECT format_string('Hex: %#08x', 255);
----
Hex: 0x0000ff
+# ================================
+# Shared numeric final assembly
+# ================================
+
+## Signed integer parentheses and zero padding include the suffix in the width
+query T
+SELECT format_string('[%(08d]', -12::BIGINT);
+----
+[(000012)]
+
+## Signed integer parentheses stay before right padding
+query T
+SELECT format_string('[%-(8d]', -12::BIGINT);
+----
+[(12) ]
+
+## Signed integer force-sign and zero padding
+query T
+SELECT format_string('[%+08d]', 12::BIGINT);
+----
+[+0000012]
+
+## Signed integer space-sign and zero padding
+query T
+SELECT format_string('[% 08d]', 12::BIGINT);
+----
+[ 0000012]
+
+## Negative integers keep their minus sign with force-sign or space-sign flags
+query TT
+SELECT
+ format_string('[%+08d]', -12::BIGINT),
+ format_string('[% 08d]', -12::BIGINT);
+----
+[-0000012] [-0000012]
+
+## Signed integer grouping, force-sign, and width
+query T
+SELECT format_string('[%+,12d]', 1234567::BIGINT);
+----
+[ +1,234,567]
+
+## Signed integer array input uses the same final assembly
+query T rowsort
+SELECT format_string('[%(08d]', value)
Review Comment:
Could we add a SQL-level `%d` regression test for
`-9223372036854775808::BIGINT` here? It would also be nice to cover grouping or
parentheses with this value. Using `unsigned_abs()` handles this boundary
correctly, but the new tests currently only cover smaller negative values. An
explicit regression test would help make sure we do not accidentally
reintroduce the previous `abs()` overflow behavior.
--
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]