Unable to insert nested json into cassandra

136 Views Asked by At

I am new in Cassandra. I have created one sample table. Right now facing problem during insert.

created employee like below :

create table employee(
  emp_id int PRIMARY KEY,
  first_name text,
  last_name text,
  department text,
  skillswithrank map
);

Written query :

INSERT INTO company.employee(emp_id,first_name,last_name,department,skillswithrank )
 VALUES (1,'sam', 'watson', 'IT', [{"nodejs":4},{"angularjs":4},{"expressjs":4}]);

I am stuck at this point.

1

There are 1 best solutions below

6
On

You're trying to insert a list of maps, instead of map, so your insert doesn't match to table definition. Plus you're using incorrect syntax for strings in the map.

you need to write insert as:

INSERT INTO company.employee(emp_id,first_name,last_name,department,skillswithrank )
  VALUES (1,'sam', 'watson', 'IT', {'nodejs':4, 'angularjs':4, 'expressjs':4]);