2
此其聲明的順序以下是我用來創建表的查詢:卡桑德拉排序按目前只支持列的順序在主鍵
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"
我怎樣才能做到這一點?
'timestamp'是你的主鍵列嗎? –
你的查詢似乎是正確的。但你的MV架構不正確,它應該是'CLUSTERING ORDER BY BY(timestamp ASC,msguuid DESC)' –
當我這樣做時,我沒有得到最後50行。基本上我想要做的是抓住插入的最後50行,然後按升序對結果進行排序。我試圖做甚至可能嗎? –