Cassandra 3.11.4 CQL GROUP BY Not working

喜夏-厌秋 提交于 2019-12-11 12:44:41

问题


I might be missing something very basic, or there is something very wrong; I am using Apache Cassandra 3.11.4. Version details are as follows:

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.7.0 | CQL spec 3.4.2 | Native protocol v4]

I have the following table and I want to get the count of individual citizen-ship status.

CREATE TABLE population.residents (
residentId bigint,
name varchar,
office varchar,
dob date,
citizen text,
PRIMARY KEY((residentId), dob)
);

CREATE MATERIALIZED VIEW population.residents_citizen AS
    SELECT citizen, dob, residentid, name, office
    FROM population.residents
    WHERE citizen IS NOT NULL AND residentid IS NOT NULL AND dob IS NOT NULL
    PRIMARY KEY (citizen, dob, residentid);

The following error is obtained when I try to query:

cqlsh> select citizen, count(residentId) from population.residents_citizen GROUP BY citizen;
SyntaxException: line 1:68 missing EOF at 'GROUP' (...(residentId) from population.residents_citizen [GROUP] BY...)
cqlsh> select citizen, count(residentId) from population.residents_citizen_1 
GROUP BY citizen, residentId;
SyntaxException: line 1:70 missing EOF at 'GROUP' (...(residentId) from population.residents_citizen_1 [GROUP] BY...)
cqlsh> select citizen, count(residentId) from population.residents_citizen_1 GROUP BY residentId, citizen;
SyntaxException: line 1:70 missing EOF at 'GROUP' (...(residentId) from population.residents_citizen_1 [GROUP] BY...)
cqlsh> select citizen, count(residentId) from population.residents_citizen_1 GROUP BY citizen, dob, residentId;
SyntaxException: line 1:70 missing EOF at 'GROUP' (...(residentId) from population.residents_citizen_1 [GROUP] BY...)

My Data looks like as below:

cqlsh> select * from population.residents;

 residentid | dob        | citizen | name              | office
------------+------------+---------+-------------------+----------------------------------------
      25966 | 2019-01-04 |       N |        Carl Sykes |              Leo Cras Vehicula Limited
     921412 | 2018-12-13 |       N |    Brady Harrison |          Nulla In Tincidunt Consulting
     521367 | 2019-11-18 |       Y |      Aaron Norton |      Pharetra Sed Hendrerit Associates
     843096 | 2020-02-03 |       N |      Preston Leon |                        A Felis Limited
     460162 | 2019-01-17 |       N |      Neville Good |                   Odio Aliquam Company
     187360 | 2018-12-09 |       Y |     Emery Pittman |                Arcu Ac Orci Foundation

Some advice is really appreciated!

来源:https://stackoverflow.com/questions/56241570/cassandra-3-11-4-cql-group-by-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!