Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra + data insertion + set<FROZEN<map<text,text>>>

My column family structure is:

create table mykeyspc."test" (
id int PRIMARY KEY,
val set<frozen<map<text,text>>>
);

when I am inserting data through CQL shell

insert into "test" JSON '{"id":1,"val":{"ab","bc"}}';
Error: INVALIDREQUEST: code=2200 [Invalid query] message="Counld not decode JSon string as 
map:org.codehaus.jackson.jsonParseException: Unexpected character{'{'{ code 123}) 

or

insert into "test" (id,val) values (1,{{'ab','bc'},{'sdf','name'}});
Error: INVALIDREQUEST: code=2200 [Invalid query] message="INVALID SET LITERAL FOR
VAL:value{'a','b'} is not of type frozen<map<text,text>>"
like image 414
Rahul Patel Avatar asked Mar 25 '26 16:03

Rahul Patel


1 Answers

In your second example, try separating the map key/values with colons : instead of commas.

aploetz@cqlsh:stackoverflow> INSERT INTO mapOfSet (id,val) 
                             VALUES (1,{{'ab':'bc'},{'sdf':'name'}});
aploetz@cqlsh:stackoverflow> SELECT * FROm mapofset WHERE id=1;

 id | val
----+---------------------------------
  1 | {{'ab': 'bc'}, {'sdf': 'name'}}

(1 rows)
like image 119
Aaron Avatar answered Mar 27 '26 09:03

Aaron