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

SELECT JSON prints null on empty strings

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 3.11.3, 4.0, 4.0-alpha1
    • Component/s: Legacy/CQL
    • Labels:
      None
    • Environment:

      Cassandra 3.11.2, Ubuntu 16.04 LTS

       

    • Severity:
      Normal
    • Since Version:

      Description

      SELECT JSON reports an empty string as null.

       

      Example:

      cqlsh:unittest> create table test(id INT, name TEXT, PRIMARY KEY(id));
      cqlsh:unittest> insert into test (id, name) VALUES (1, 'Foo');
      cqlsh:unittest> insert into test (id, name) VALUES (2, '');
      cqlsh:unittest> insert into test (id, name) VALUES (3, null);
      
      cqlsh:unittest> select * from test;
      
      id | name
      ----+------
        1 |  Foo
        2 |     
        3 | null
      
      (3 rows)
      
      cqlsh:unittest> select JSON * from test;
      
      [json]
      --------------------------
      {"id": 1, "name": "Foo"}
      {"id": 2, "name": null}
      {"id": 3, "name": null}
      
      (3 rows)

       

      This even happens, if the string is part of the Primary Key, which makes the generated string not insertable.

       

      cqlsh:unittest> create table test2 (id INT, name TEXT, age INT, PRIMARY KEY(id, name));
      cqlsh:unittest> insert into test2 (id, name, age) VALUES (1, '', 42);
      cqlsh:unittest> select JSON * from test2;
      
      [json]
      ------------------------------------
      {"id": 1, "name": null, "age": 42}
      
      (1 rows)
      
      cqlsh:unittest> insert into test2 JSON '{"id": 1, "name": null, "age": 42}';
      InvalidRequest: Error from server: code=2200 [Invalid query] message="Invalid null value in condition for column name"

       

      On an older version of Cassandra (3.0.8) does not have this problem.

        Attachments

          Activity

            People

            • Assignee:
              fcofdezc Francisco Fernandez
              Reporter:
              nob13 Norbert Schultz
              Authors:
              Francisco Fernandez
              Reviewers:
              Benjamin Lerer
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: