-
Create a
calendar
table with a collection of typelist
.
CREATE TABLE calendar (key int PRIMARY KEY, years list<int>);
-
Create an SAI index using the collection’s
years
column.
CREATE CUSTOM INDEX ON calendar(years) USING 'StorageAttachedIndex';
-
Insert some random
int
list data foryears
, just for demo purposes.
Notice the |
INSERT INTO calendar (key, years) VALUES (0, [1990,1996]);
INSERT INTO calendar (key, years) VALUES (1, [2000,2010]);
INSERT INTO calendar (key, years) VALUES (2, [2001,1990]);
-
Query with
CONTAINS
example from the list:
-
CQL
-
Result
SELECT * FROM calendar WHERE years CONTAINS 1990;
key | years
-----+--------------
0 | [1990, 1996]
2 | [2001, 1990]
(2 rows)