我知道已经晚了。IMO 模型几乎没有细微的变化就足以达到预期的效果。可以做的是拥有与被查询集合的幂集成员一样多的行。
CREATE TABLE data_points_ks.mytable (
codes frozen<set<int>>,
tid timeuuid,
raw text,
type text,
PRIMARY KEY (codes, tid)
) WITH CLUSTERING ORDER BY (tid ASC)
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {12}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {34}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {12, 34}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {53}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {12, 53}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {34, 53}, '{sdafb=safd}', 'cmd');
INSERT INTO mytable (tid, codes, raw, type) VALUES (now(), {12, 34, 53}, '{sdafb=safd}', 'cmd');
tid | codes | raw | type
--------------------------------------+--------------+--------------+------
8ae81763-1142-11e8-846c-cd9226c29754 | {34, 53} | {sdafb=safd} | cmd
8746adb3-1142-11e8-846c-cd9226c29754 | {12, 53} | {sdafb=safd} | cmd
fea77062-1142-11e8-846c-cd9226c29754 | {34} | {sdafb=safd} | cmd
70ebb790-1142-11e8-846c-cd9226c29754 | {12, 34} | {sdafb=safd} | cmd
6c39c843-1142-11e8-846c-cd9226c29754 | {12} | {sdafb=safd} | cmd
65a954f3-1142-11e8-846c-cd9226c29754 | null | {sdafb=safd} | cmd
03c60433-1143-11e8-846c-cd9226c29754 | {53} | {sdafb=safd} | cmd
82f68d70-1142-11e8-846c-cd9226c29754 | {12, 34, 53} | {sdafb=safd} | cmd
那么下面的查询就足够了,不需要任何过滤。
SELECT * FROM mytable
WHERE codes = {12, 34};
或者
SELECT * FROM mytable
WHERE codes = {34};