Reputation: 113
Here is the type I have created,
CREATE TYPE urs.dest (
destinations frozen<list<text>>);
And here is the table ,
CREATE TABLE urs.abc (
id int,
locations map<text, frozen<dest>>,
PRIMARY KEY(id));
When I try to insert values from cqlsh,
try 1:
insert into urs.abc (id, locations ) values (1, {'coffee': { 'abcd', 'efgh'}});
try 2:
insert into urs.abc (id, locations ) values (1, {'coffee': ['abcd', 'efgh']});
try 3:
insert into urs.abc (id) values (1);
update urs.abc set locations = locations + {'coffee': {'abcd','qwer'}} where id=1;
I'm getting the below error,
Error from server: code=2200 [Invalid query] message="Invalid map literal for locations: value {'abcd', 'qwer'} is not of type frozen<dest>"
Can anyone please let me know the correct way to add value to my UDT?
Upvotes: 1
Views: 1925
Reputation: 1216
Table creation seems fine
To insert to the table to urs.abc
use this
insert into urs.abc (id, locations ) values (1, {'coffee':{ destinations: ['abcd', 'efgh']}});
You are missing the field name destinations
.
Upvotes: 2