andygrove commented on code in PR #416:
URL: https://github.com/apache/datafusion-spark/pull/416#discussion_r4711203209


##########
crates/sqllogictest/test_files/string/format_string.slt:
##########
@@ -2549,3 +2549,19 @@ query T
 SELECT format_string('Large octal: %o', 9223372036854775807::BIGINT);
 ----
 Large octal: 777777777777777777777
+
+# ================================
+# Zero with %e and %g
+# ================================
+
+## Java's Formatter prints zero with exponent 0: 0.000000e+00 for %e
+query T
+SELECT format_string('%e', 0.0::DOUBLE);
+----
+0.000000e+00
+
+## and 0.00000 for %g with the default precision
+query T
+SELECT format_string('%g', 0.0::DOUBLE);
+----
+0.00000

Review Comment:
   Could you add a negative zero case and an array-input case as well? For 
example:
   
   ```
   query T
   SELECT format_string('[%e|%g|%G]', CAST('-0.0' AS DOUBLE), CAST('-0.0' AS 
DOUBLE), CAST('-0.0' AS DOUBLE));
   ----
   [-0.000000e+00|-0.00000|-0.00000]
   
   query T
   SELECT format_string('%g', a) FROM (VALUES (CAST(0.0 AS DOUBLE)), (CAST(1.5 
AS DOUBLE)), (CAST(NULL AS DOUBLE))) t(a);
   ----
   0.00000
   1.50000
   null
   ```
   
   Both match Spark and pass on this branch. They lock in the fix on the array 
path and for `-0.0`, which is the input a zero check most often misses.



-- 
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]

Reply via email to