如何从列表中的de UDT获取值?
我需要像这样在Cassandra CQLSH中进行查询:
SELECT nome, grades.score FROM rest_grades WHERE grades.score > 10 ALLOW FILTERING;
下面是我的数据类型,TABLE和一个INSERT示例的创建,以填充表rest_grades:
-- TYPE
CREATE TYPE address (building text, coord FROZEN<tuple<double, double>>, rua text, zipcode text);
CREATE TYPE grade (date timestamp, grade text, score int);
-- TABLE
CREATE TABLE rest_grades (
address FROZEN<address>,
localidade text,
gastronomia text,
grades list<FROZEN<grade>>,
nome text,
restaurant_id text,
PRIMARY KEY (restaurant_id)
);
-- INSERT example
INSERT INTO rest_grades JSON '{
"address":{
"building":"469",
"coord":[
-73.961704,
40.662942
],
"rua":"Flatbush Avenue",
"zipcode":"11225"
},
"localidade":"Brooklyn",
"gastronomia":"Hamburgers",
"grades":[
{"date":1419897600000,"grade":"A","score":8},
{"date":1404172800000,"grade":"B","score":23},
{"date":1367280000000,"grade":"A","score":12},
{"date":1336435200000,"grade":"A","score":12}
],
"nome":"Wendy''S",
"restaurant_id":"30112340"
}';