Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-2032: [C#] Add support for NaN, Infinity and -Infinity in JsonDecoder #3070

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zcsizmadia
Copy link
Contributor

What is the purpose of the change

JsonEncoder uses special string values to represent NaN, Infinity and -Infinity values for float and double values, but JsonDecoder does not accept these string values. This change adds support for these special values to JsonDecoder.

Verifying this change

This change added tests and can be verified as follows:

  • The change adds an unit tests which verifies all 6 special cases:
    • NaN for float fields
    • NaN for double fields
    • Infinity for float fields
    • Infinity for double fields
    • -Infinity for float fields
    • -Infinity for double fields
  • These values are defined in Jackson.
    StdDeserializer

Documentation

  • This PR doesn't introduce a new feature but implements a behavior which is not documented at all.
  • The Avro spec doesn't mention how these special cases are handled in JSON (RFC 8259 does not define numeric literals for NaN, Infinity and -Infinity)
  • JsonEncoder/JsonDecoder resemble the behavior of Jackson

@github-actions github-actions bot added the C# label Aug 7, 2024
@zcsizmadia
Copy link
Contributor Author

Same as #3066

martin-g added a commit that referenced this pull request Aug 7, 2024
…Infinity"

This is what the Java SDK (via Jackson library) supports (#3066).
This is what the C# SDK also would support (#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit that referenced this pull request Aug 7, 2024
…Infinity"

This is what the Java SDK (via Jackson library) supports (#3066).
This is what the C# SDK also would support (#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit that referenced this pull request Aug 7, 2024
…Infinity"

This is what the Java SDK (via Jackson library) supports (#3066).
This is what the C# SDK also would support (#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit that referenced this pull request Aug 7, 2024
…Infinity"

This is what the Java SDK (via Jackson library) supports (#3066).
This is what the C# SDK also would support (#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit that referenced this pull request Aug 7, 2024
…g numbers with Java and C# (#3073)

* AVRO-4024: [Rust] Improve the error messages when parsing unknown String into Value::Float/Double

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* AVRO-4024: [Rust] Accept only "Nan", "INF", "-INF", "Infinity" and "-Infinity"

This is what the Java SDK (via Jackson library) supports (#3066).
This is what the C# SDK also would support (#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

---------

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit that referenced this pull request Aug 7, 2024
…g numbers with Java and C# (#3073)

* AVRO-4024: [Rust] Improve the error messages when parsing unknown String into Value::Float/Double

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* AVRO-4024: [Rust] Accept only "Nan", "INF", "-INF", "Infinity" and "-Infinity"

This is what the Java SDK (via Jackson library) supports (#3066).
This is what the C# SDK also would support (#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

---------

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
(cherry picked from commit dffc13a)
martin-g added a commit to apache/avro-rs that referenced this pull request Sep 23, 2024
…g numbers with Java and C# (#3073)

* AVRO-4024: [Rust] Improve the error messages when parsing unknown String into Value::Float/Double

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

* AVRO-4024: [Rust] Accept only "Nan", "INF", "-INF", "Infinity" and "-Infinity"

This is what the Java SDK (via Jackson library) supports (apache/avro#3066).
This is what the C# SDK also would support (apache/avro#3070)

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

---------

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants