这是我用来创建表的查询:
CREATE TABLE test.comments (msguuid timeuuid, page text, userid text, username text, msg text, timestamp int, PRIMARY KEY (timestamp, msguuid));
然后创建一个物化视图:
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"
我怎样才能做到这一点?
发布于 2017-06-06 05:15:05
物化视图规则基本上与“标准”表相同。如果您想要一个特定的顺序,则必须在群集键中指定该顺序。
因此,您必须将您的timestamp
放到集群部分。
发布于 2018-04-13 07:40:32
群集顺序语句应该修改如下://不要忘记将主键放在时间戳之前,放入()
CLUSTERING ORDER BY ((msguuid DESC), timestamp ASC)
https://stackoverflow.com/questions/44379302
复制相似问题