【发布时间】:2017-04-24 05:20:08
【问题描述】:
我正在阅读这篇文章,它展示了如何在 cassandra 中使用 IN 子句编写查询
https://www.datastax.com/dev/blog/a-deep-look-to-the-cql-where-clause
我创建了下表
create table foo2(id bigint, bid bigint, data set<bigint>, primary key (id, bid));
insert into foo2 (id, bid, data) values (1, 1, {1, 2});
insert into foo2 (id, bid, data) values (1, 2, {3, 4});
insert into foo2 (id, bid, data) values (1, 3, {5, 6});
现在我编写查询
select * from foo2 where id = 1 and bid IN (1, 2, 3);
当查询选择集合时,不能通过关系限制集群列。
我搜索了这个错误并找到了这个
https://issues.apache.org/jira/browse/CASSANDRA-12654
它说问题已在 Cassandra 4.0 中解决,但我正在使用
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
是否有解决方法(除了任何 Cassandra 问题change your schema 的所有答案之母)
有人指点这里:Cassandra IN query not working if table has SET type column
但这并不是问题没有明确的答案。
【问题讨论】:
-
Ashraful.. 这个问题没有明确的答案。所以你指给我一个未回答的问题。
-
这是 cassandra 的限制,如果您在表中使用 set、list 或 map,则不能使用带有集群键的 in 子句
标签: cassandra