JSON is popular enough that not supporting it is becoming a competitive weakness. We can add JSON support in a way that is compatible with our performance goals by mapping JSON to an existing schema: one JSON documents maps to one CQL row.

      Thus, it is NOT a goal to support schemaless documents, which is a misfeature [1] [2] [3]. Rather, it is to allow a convenient way to easily turn a JSON document from a service or a user into a CQL row, with all the validation that entails.

      Since we are not looking to support schemaless documents, we will not be adding a JSON data type (CASSANDRA-6833) a la postgresql. Rather, we will map the JSON to UDT, collections, and primitive CQL types.

      Here's how this might look:

      CREATE TYPE address (
        street text,
        city text,
        zip_code int,
        phones set<text>
      CREATE TABLE users (
        id uuid PRIMARY KEY,
        name text,
        addresses map<text, address>
      INSERT INTO users JSON
      {‘id’: 4b856557-7153,
         ‘name’: ‘jbellis’,
         ‘address’: {“home”: {“street”: “123 Cassandra Dr”,
                              “city”: “Austin”,
                              “zip_code”: 78747,
                              “phones”: [2101234567]}}};
      SELECT JSON id, address FROM users;

      (We would also want to_json and from_json functions to allow mapping a single column's worth of data. These would not require extra syntax.)



        1. 7970-trunk-v1.txt
          191 kB
          Tyler Hobbs
        2. 7970-trunk-v2.txt
          204 kB
          Tyler Hobbs

          Issue Links



              • Assignee:
                thobbs Tyler Hobbs
                jbellis Jonathan Ellis
                Sylvain Lebresne
              • Votes:
                5 Vote for this issue
                33 Start watching this issue


                • Created: