gpt4 book ai didi

Cassandra Order by 目前仅支持按照 PRIMARY KEY 中声明的顺序对列进行排序

转载 作者:行者123 更新时间:2023-12-03 08:07:24 27 4
gpt4 key购买 nike

这是我用来创建表的查询:

CREATE TABLE test.comments (msguuid timeuuid, page text, userid text, username text, msg text, timestamp int, PRIMARY KEY (timestamp, msguuid));

然后我创建一个物化 View :

CREATE MATERIALIZED VIEW test.comments_by_page AS
SELECT *
FROM test.comments
WHERE page IS NOT NULL AND msguuid IS NOT NULL
PRIMARY KEY (page, timestamp, msguuid)
WITH CLUSTERING ORDER BY (msguuid DESC);

我想获取按时间戳升序排序的最后 50 行。

这是我正在尝试的查询:

SELECT * FROM test.comments_by_page WHERE page = 'test' AND timestamp < 1496707057 ORDER BY timestamp ASC LIMIT 50;

然后出现此错误:InvalidRequest: code=2200 [Invalid query] message="Order by currently only support the ordering of columns following their declared order in the PRIMARY KEY"

我怎样才能做到这一点?

最佳答案

物化 View 规则与“标准”表规则基本相同。如果你想要一个特定的顺序,你必须在集群键中指定。

因此您必须将您的时间戳 放入聚类部分。

关于Cassandra Order by 目前仅支持按照 PRIMARY KEY 中声明的顺序对列进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44379302/

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