andygrove commented on code in PR #3018:
URL: https://github.com/apache/datafusion-comet/pull/3018#discussion_r2662782397


##########
native/spark-expr/src/json_funcs/to_json.rs:
##########
@@ -181,6 +188,23 @@ fn escape_string(input: &str) -> String {
     escaped_string
 }
 
+fn normalize_special_floats(arr: &StringArray) -> ArrayRef {
+    let mut builder = StringBuilder::with_capacity(arr.len(), arr.len() * 8);
+
+    for i in 0..arr.len() {
+        if arr.is_null(i) {
+            builder.append_null();
+        } else {
+            match arr.value(i) {
+                "Infinity" | "-Infinity" | "NaN" => builder.append_null(),

Review Comment:
   Spark doesn't follow the JSON spec:
   
   ```
   scala> spark.sql("""SELECT to_json(struct(cast('Infinity' as double) as inf, 
        |                       cast('NaN' as double) as nan))""").show(false)
   
+----------------------------------------------------------------------------+
   |to_json(struct(CAST(Infinity AS DOUBLE) AS inf, CAST(NaN AS DOUBLE) AS 
nan))|
   
+----------------------------------------------------------------------------+
   |{"inf":"Infinity","nan":"NaN"}                                              
|
   
+----------------------------------------------------------------------------+
   ```
   



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