我在CQL中创建了下表:
CREATE TABLE new_table (
idRestaurant INT,
restaurant map<text,varchar>,
InspectionDate date,
ViolationCode VARCHAR,
ViolationDescription VARCHAR,
CriticalFlag VARCHAR, Score INT, GRADE VARCHAR,
PRIMARY KEY (InspectionDate )) ;
然后,我已经通过jar
插入数据,我得到的restaurant column
值就像json/dictionary
select restarutant from new_table;
就像以下结果:
在正常的SQL中,选择json列的键值应该是select json_col.key from table
但是这对CQL不起作用,我如何选择JSON的键值作为列或WHERE条件过滤?
非常感谢
我最好将表的架构更改为以下内容,而不是使用map:
CREATE TABLE new_table (
idRestaurant INT,
restaurant_key text,
restaurant_value text,
InspectionDate date,
ViolationCode VARCHAR,
ViolationDescription VARCHAR,
CriticalFlag VARCHAR,
Score INT,
GRADE VARCHAR,
PRIMARY KEY (InspectionDate, restaurant_key )) ;
然后你可以选择基于restaurant_key
的单个行和查询,如:
select * from new_table where idRestaurant = ? and restaurant_key = ?
或者为餐厅选择一切:
select * from new_table where idRestaurant = ?