在cql问题中选择查询

dxxyhpgq  于 2021-06-10  发布在  Cassandra
关注(0)|答案(1)|浏览(374)

我正在尝试获取cassandra db中一个表的计数,我正在运行以下查询:

select count(*) 
from bssapi.call_detail_records 
WHERE 
year = 2020 
and month = 3
and event_at > '2020-03-01 07:45:51+0000' ALLOW FILTERING;

我得到的错误是:

InvalidRequest: code=2200 [Invalid query] message="Partitioning column "year" cannot be restricted because the preceding column ("ColumnDefinition{name=subscription_id, type=org.apache.cassandra.db.marshal.UTF8Type, kind=PARTITION_KEY, componentIndex=0, indexName=null, indexType=null}") is either not restricted or is restricted by a non-EQ relation"

当我通过添加订阅id来过滤查询时,系统会正确返回计数,只有当我对所有表运行计数时,才会出现此问题。

fnatzsnv

fnatzsnv1#

我得到了这个问题的解决方案,我使用了下面的查询:

select COUNT(*) from bssapi.call_detail_records WHERE event_at > '2020-03-22 07:45:51+0000' ALLOW FILTERING;

相关问题