首页 文章

在查询选择集合时,无法通过关系限制聚类列

提问于
浏览
3

我正在阅读这篇文章,该文章展示了如何使用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

但这并不是一个没有明确答案的问题 .

2 回答

  • 4

    使用 column names 而不是 * 将解决问题 . 在您的情况下,查询应为: select id,bid,data from foo2 where id = 1 and bid IN (1, 2, 3);

  • 4

    您可能不喜欢这个答案,但您必须稍微更改架构才能解决此问题 . 通过使用 frozen ,问题将消失 . 请注意,此问题也影响使用 frozen 修复的UDT 's and that for them it also get' .

相关问题