2017-06-17 56 views
0

我有此表在卡桑德拉密鑰空間:集團在CQL的卡桑德拉DB不工作

create table hashtags(
id uuid, 
text text, 
frequence int, 
primary key ((text), frequence, id)) 
with clustering order by (frequence desc, id asc); 

所以我text爲分區鍵和frequence, id作爲聚集鍵。 據Cassandra documentation關於爲GROUP BY操作的支持,我應該能夠運行這類查詢:

select text, sum(frequence) from hashtags 
group by text; 

但我不斷收到此錯誤:

com.datastax.driver.core.exceptions.SyntaxError: line 2:0 no viable alternative at input 'group' (...text, sum(frequence) from [hashtags] group...)

有什麼我從誤解指南?我怎樣才能正確運行這個查詢? 感謝您的幫助。

+0

? –

回答

1

它在Apache Cassandra 3.10上爲我工作。我嘗試從cqlsh。

cqlsh:test> select * from hashtags ; 
 

 
text | frequence | id 
 
-------+-----------+-------------------------------------- 
 
hello |   5 | 07ef8ee4-6492-4112-babb-fc3ac2893701 
 
hello |   4 | 3f6f3b1d-4a33-4a07-ad60-2274a9dc5577 
 
hello |   1 | 4adf7e2a-f3b9-41eb-85cf-f4c4bdc5d322 
 
    hi |   7 | 71718f46-455e-4012-a306-f31f1cb2454a 
 

 
(4 rows) 
 
cqlsh:test> select text, sum(frequence) from hashtags group by text; 
 

 
text | system.sum(frequence) 
 
-------+----------------------- 
 
hello |     10 
 
    hi |      7 
 

 
(2 rows) 
 

 
Warnings : 
 
Aggregation query used without partition key

您正在使用哪個版本的卡珊德拉
+0

所以我想我沒有使用最新版本。謝謝你測試它,畢竟我並沒有錯。 – sirdan