gpt4 book ai didi

cassandra - Cassandra 中的 IN 运算符不适用于具有类型集合(Map 或 List)列的表

转载 作者:行者123 更新时间:2023-12-01 00:59:11 24 4
gpt4 key购买 nike

我正在研究 Cassandra,试图了解它是如何工作的。使用 IN 运算符时遇到了一些奇怪的事情。例子:

table :

CREATE TABLE test_time (
name text,
age int,
time timeuuid,
"timestamp" timestamp,
PRIMARY KEY ((name, age), time)
)

我插入了一些虚拟数据。使用 IN 运算符如下:
SELECT * from test_time
where name="9" and age=81
and time IN (c7c88000-190e-11e4-8000-000000000000, c7c88000-190e-11e4-7000-000000000000);

它工作正常。

然后,添加一个类型为 Map 的列.表将如下所示:
CREATE TABLE test_time (
name text,
age int,
time timeuuid,
name_age map<text, int>,
"timestamp" timestamp,
PRIMARY KEY ((name, age), time)
)

在执行相同的查询时,我收到以下错误:

Bad Request: Cannot restrict PRIMARY KEY part time by IN relation as a collection is selected by the query



从上面的例子中,我们可以说,如果表中有任何类型为集合(Map 或 List)的列,则 IN 运算符不起作用。

我不明白为什么它的行为是这样的。如果我在这里遗漏了什么,请告诉我。提前致谢。

最佳答案

是的……这是一个限制。您可以执行以下操作:

  • select * from ...where name='9' and age=81 and time > x and time < y
  • select [columns except collection] from ...where name='9' and age=81 and time in (...)

  • 然后您可以过滤客户端,或执行另一个查询。

    关于cassandra - Cassandra 中的 IN 运算符不适用于具有类型集合(Map 或 List)列的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25076283/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com