cetra3 opened a new pull request, #11513: URL: https://github.com/apache/arrow-rs/pull/11513
# Which issue does this PR close? - N/A # Rationale for this change `VariantToJson` writes `Variant::Float` and `Variant::Double` with `Display`, which drops the fractional part of a whole-valued float. `Variant::Double(2.0)` renders as `2`, and `Variant::Float(0.0)` as `0`. The JSON then reads as an integer, so a consumer that distinguishes integers from floats sees a different type, and a JSON string rebuilt from a Variant differs from the JSON the Variant was parsed from. # What changes are included in this PR? - Float and double values are formatted with `ryu`, as `serde_json` and `arrow-json` already do. `2.0` renders as `2.0`. - `ryu` is added to `parquet-variant-json`. It is already a dependency of `arrow-cast` and `arrow-json`, so the dependency tree does not change. `ryu` also uses exponent notation for very large and very small magnitudes, for example `1e21` and `1e-7`, where `Display` writes all the digits. Both forms are valid JSON. # Are these changes tested? Yes. The `to_json` tests now expect `0.0` for `Variant::Float(0.0)`, add a `Variant::Double(2.0)` case, and check that an object with a whole-valued double field renders it as `2.0`. # Are there any significant user-facing changes? Yes. The JSON text for whole-valued floats changes: `2.0` renders as `2.0` instead of `2`. The value is unchanged. -- 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]
