[
https://issues.apache.org/jira/browse/CASSANDRA-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288682#comment-13288682
]
Jonathan Ellis edited comment on CASSANDRA-3647 at 6/4/12 5:07 PM:
-------------------------------------------------------------------
One possible syntax, allowing append/add/put for list/set/map and full
overwrites. For set and map we can additionally support removal. (I've called
this operation {{discard}} after the Python Set method for "remove an item if
it exists, otherwise do not complain," but alternatives are reasonable.)
{code}
CREATE TABLE foo(
k uuid PRIMARY KEY,
L list<int>,
M map<text, int>,
S set<int>
);
UPDATE foo SET L = L.append(1) WHERE k = 'b017f48f-ae67-11e1-9096-005056c00008';
UPDATE foo SET L = '[2, 3]' WHERE ... ; -- do we need/want to require quoting?
UPDATE foo SET S = S.add(1) WHERE ... ;
UPDATE foo SET S = '{2, 3}' WHERE ... ; -- JSON does not define a set type or
syntax. this is Python's syntax for set literals
UPDATE foo SET S = S.discard(2) WHERE ... ;
UPDATE foo SET M = M.put('ocd', 1) WHERE ... ;
UPDATE foo SET M = '{"cod": 2, "dog": 3}' WHERE ... ; -- note double quotes
forced if we require quoting the map literal
UPDATE foo SET M = M.discard('cod') WHERE ... ;
{code}
was (Author: jbellis):
One possible syntax, allowing append/add/put for list/set/map and full
overwrites. For set and map we can additionally support removal. (I've called
this operation {{discard}} after the Python Set method for "remove an item if
it exists, otherwise do not complain," but alternatives are reasonable.)
{code}
CREATE TABLE foo(
k uuid PRIMARY KEY,
L list<int>,
M map<text, int>,
S set<int>
);
UPDATE foo SET L = L.append(1)
UPDATE foo SET L = '[2, 3]' -- do we need/want to require quoting?
UPDATE foo SET S = S.add(1)
UPDATE foo SET S = '{2, 3}' -- JSON does not define a set type or syntax. this
is Python's syntax for set literals
UPDATE foo SET S = S.discard(2)
UPDATE foo SET M = M.put('ocd', 1)
UPDATE foo SET M = '{"cod": 2, "dog": 3}' -- note double quotes forced if we
require quoting the map literal
UPDATE foo SET M = M.discard('cod');
{code}
> Support set and map value types in CQL
> --------------------------------------
>
> Key: CASSANDRA-3647
> URL: https://issues.apache.org/jira/browse/CASSANDRA-3647
> Project: Cassandra
> Issue Type: New Feature
> Components: API, Core
> Reporter: Jonathan Ellis
> Labels: cql
>
> Composite columns introduce the ability to have arbitrarily nested data in a
> Cassandra row. We should expose this through CQL.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira