HendrikHuebner opened a new pull request, #12478:
URL: https://github.com/apache/arrow-rs/pull/12478

   
   > [!IMPORTANT]
   >
   > Before opening this PR, [enable CI in your 
fork](https://github.com/apache/arrow-rs/blob/main/CONTRIBUTING.md#pull-requests-from-forks).
   >
   > **Delete this notice after enabling CI.**
   
   # Which issue does this PR close?
   
   - Relates to #11724
   
   # Rationale for this change
   
   The JSON writer always writes NaN and infinity as `null`, so those values 
are lost. The JSON spec does not support (unquoted) NaN/Infinity but users may 
want to write them anyways instead of losing the information, so many JSON 
writers support quoted/unquoted as an extension.
   
   I'm open to adding unquoted support too (as a separate option).
   
   # What changes are included in this PR?
   
   - `WriterBuilder::with_non_finite_floats_as_strings(bool)` and 
`EncoderOptions::with_non_finite_floats_as_strings(bool)`, plus getters. Off by 
default.
   - When enabled, Float16/Float32/Float64 NaN, `+inf` and `-inf` are written 
as `"NaN"`, `"Infinity"` and `"-Infinity"`. Finite values are unchanged.
   
   The output stays valid JSON. I didn't add an option for bare 
`NaN`/`Infinity` tokens because that output isn't valid JSON.
   
   # Are these changes tested?
   
   Yes:
   - a writer test covering default and opt-in output for all three float 
types, including inside a list
   - a write-then-read round-trip test
   
   # Are there any significant user-facing changes?
   
   There are new public methods on `WriterBuilder` and `EncoderOptions`. 
Default behaviour is unchanged.
   
   # AI usage disclosure
   
   An AI assistant helped write the implementation, the tests and this 
description. I reviewed the change and ran the tests locally.
   


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