tustvold commented on code in PR #5197:
URL: https://github.com/apache/arrow-rs/pull/5197#discussion_r1454823157


##########
arrow-json/src/writer.rs:
##########
@@ -469,11 +469,67 @@ fn set_column_for_json_rows(
                 row.insert(col_name.to_string(), 
serde_json::Value::Object(obj));
             }
         }
+        DataType::Decimal128(_precision, _scale) | 
DataType::Decimal256(_precision, _scale) => {
+            to_json_float(rows, array, col_name, explicit_nulls)?;
+        }
         _ => {
             return Err(ArrowError::JsonError(format!(
-                "data type {:?} not supported in nested map for json writer",
+                "data type {:?} not supported for json writer",
                 array.data_type()
-            )))
+            )));
+        }
+    }
+    Ok(())
+}
+
+fn to_json_float(
+    rows: &mut [Option<JsonMap<String, Value>>],
+    array: &ArrayRef,
+    col_name: &str,
+    explicit_nulls: bool,
+) -> Result<(), ArrowError> {
+    let options = FormatOptions::default();
+    let formatter = ArrayFormatter::try_new(array.as_ref(), &options)?;

Review Comment:
   The problem is you are then parsing to a f64 which will result in precision 
loss, as serde_json value lacks a decimal representation you may be forced to 
instead encode decimals as JSON strings



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

Reply via email to