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

Map keys aren't properly serialized as strings in SELECT JSON queries

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 2.2.0 beta 1
    • Component/s: Legacy/CQL
    • Labels:
      None
    • Severity:
      Normal

      Description

      When I run a SELECT JSON query on a table that contains a column of type map, the JSON output doesn’t wrap the map keys with quotes, thus creating a non-standard JSON representation, which doesn’t play along with JSON parsers very well.

      Here’s an example where the map keys are actually a set:

      create table table1 (id int primary key, mymap map<frozen<set<int>>,int>);
      insert into table1 (id,mymap) values (1, {{1,2,3,4}:1});
      select json id,mymap from table1;
      

      The output is:

      {"id": 1, "mymap": {[1, 2, 3, 4]: 1}}
      

      But what I expected was that the map key, in this case the entire integer set, would be wrapped with quotes.
      The same thing happens when the key is a primitive, such as int, or when it’s another type of collection.

      I tried this with the latest version of the Cassandra codebase from the repository’s trunk (1f65a12c33).

        Attachments

        1. 9190-trunk.txt
          13 kB
          Tom Hobbs

          Activity

            People

            • Assignee:
              thobbs Tom Hobbs
              Reporter:
              gianluca Gianluca Righetto
              Authors:
              Tom Hobbs
              Reviewers:
              Jonathan Ellis
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: