Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-14377

Returning invalid JSON for NaN and Infinity float values

    XMLWordPrintableJSON

Details

    • Low

    Description

      After inserting special float values like NaN and Infinity into a table:

      CREATE TABLE testme (t1 bigint, t2 float, t3 float, PRIMARY KEY (t1));
      INSERT INTO testme (t1, t2, t3) VALUES (7, NaN, Infinity);

      and returning them as JSON...

      cqlsh:demodb> select json * from testme;
       [json]
      --------------------------------------
       {"t1": 7, "t2": NaN, "t3": Infinity}

       

      ... the result will not be validated (e.g. with https://jsonlint.com/ ) because neither NaN nor Infinity is a valid JSON value. The consensus seems to be returning JSON's `null` in these cases, based on this article https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript and other similar ones.

      Attachments

        Activity

          People

            blerer Benjamin Lerer
            Sarna Piotr Sarna
            Benjamin Lerer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: