选择CQL问题中的查询

问题描述 投票:0回答:1

我正在尝试获取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过滤查询时,系统正确返回计数,仅当我为所有表运行计数时,才会出现此问题。

cassandra cql cqlsh
1个回答
0
投票

我已获得此问题的解决方案,我改用以下查询:

select COUNT(*) from bssapi.call_detail_records WHERE event_at > '2020-03-22 07:45:51+0000' ALLOW FILTERING;
© www.soinside.com 2019 - 2024. All rights reserved.