CQL查询日期
Query date in CQL
我想 运行 通过按日期限制结果在 Cassansdra DB 中进行 CQL 查询,当我 运行 一个没有过滤的简单查询时,我得到以下结果:
select * from bssapi.call_detail_records where subscription_id = '116377120' and year = 2020 and month = 3;
我得到的结果如下:
subscription_id | year | month | event_at | id | account_unit_type | b_number | balance_after | balance_before | balance_id | basic_service_code | billable_amount | billable_unit | billing_item__code | call_case | call_destination | call_destination_type | cell_id | created_at | customer_id | data_amount | dc_event | direction_type | duration | event_type | invoice_sequence_id | lac | mcc | msisdn | network_code | product_code | reference_price | roaming_indicator | service_category | service_type | subscription_type | technical_call_case | total_with_vat | transaction_amount
-----------------+------+-------+--------------------------+--------------------------------+-------------------+------------+---------------+----------------+------------+--------------------+-----------------+---------------+--------------------+-----------+------------------+-----------------------+----------+--------------------------+-------------+-------------+-------------+----------------+----------+------------+---------------------+------+-----+------------+--------------+--------------+-----------------+-------------------+------------------+--------------+-------------------+---------------------+----------------+--------------------
XXXXXXXX | 2020 | 3 | 2020-03-01 07:45:51+0000 | POSTPAIDÿ3489472270ÿ2020-03-01 | 0 | XXXXXXXX | 0.0 | 0.0 | null | 11 | 60 | seconds | BNATCALL | 0 | 066 | national | 2730 | 2020-03-01 07:58:48+0000 | XXXXXXXXXX| 0 | CALLNAT600R | MOC | 16 | CALL | 3626608 | 0A2A | 603 | XXXXXXXXX | DZAOT | null | 5.0 | 0 | null | 1 | XXXXXXX| 1011 | 0.0 | 0.0
我想要的是只得到一天的结果,例如只得到今天“2020-03-19 07:45:51+0000”的结果,我尝试了几个查询但我无法得到正确的结果,例如我尝试了以下:
select * from bssapi.call_detail_records where subscription_id = '116377120' and created_at > '2020-03-19 00:00:00' allow filtering;
返回的错误是:
InvalidRequest: code=2200 [Invalid query] message="Partition key part year must be restricted since preceding part is"
嗯,我想你只需要像这样提供字段 event_at 的要求:
select *
from bssapi.call_detail_records
where subscription_id = '116377120'
and year = 2020
and month = 3
and event_at = '2020-03-19 07:45:51+0000';
我想 运行 通过按日期限制结果在 Cassansdra DB 中进行 CQL 查询,当我 运行 一个没有过滤的简单查询时,我得到以下结果:
select * from bssapi.call_detail_records where subscription_id = '116377120' and year = 2020 and month = 3;
我得到的结果如下:
subscription_id | year | month | event_at | id | account_unit_type | b_number | balance_after | balance_before | balance_id | basic_service_code | billable_amount | billable_unit | billing_item__code | call_case | call_destination | call_destination_type | cell_id | created_at | customer_id | data_amount | dc_event | direction_type | duration | event_type | invoice_sequence_id | lac | mcc | msisdn | network_code | product_code | reference_price | roaming_indicator | service_category | service_type | subscription_type | technical_call_case | total_with_vat | transaction_amount
-----------------+------+-------+--------------------------+--------------------------------+-------------------+------------+---------------+----------------+------------+--------------------+-----------------+---------------+--------------------+-----------+------------------+-----------------------+----------+--------------------------+-------------+-------------+-------------+----------------+----------+------------+---------------------+------+-----+------------+--------------+--------------+-----------------+-------------------+------------------+--------------+-------------------+---------------------+----------------+--------------------
XXXXXXXX | 2020 | 3 | 2020-03-01 07:45:51+0000 | POSTPAIDÿ3489472270ÿ2020-03-01 | 0 | XXXXXXXX | 0.0 | 0.0 | null | 11 | 60 | seconds | BNATCALL | 0 | 066 | national | 2730 | 2020-03-01 07:58:48+0000 | XXXXXXXXXX| 0 | CALLNAT600R | MOC | 16 | CALL | 3626608 | 0A2A | 603 | XXXXXXXXX | DZAOT | null | 5.0 | 0 | null | 1 | XXXXXXX| 1011 | 0.0 | 0.0
我想要的是只得到一天的结果,例如只得到今天“2020-03-19 07:45:51+0000”的结果,我尝试了几个查询但我无法得到正确的结果,例如我尝试了以下:
select * from bssapi.call_detail_records where subscription_id = '116377120' and created_at > '2020-03-19 00:00:00' allow filtering;
返回的错误是:
InvalidRequest: code=2200 [Invalid query] message="Partition key part year must be restricted since preceding part is"
嗯,我想你只需要像这样提供字段 event_at 的要求:
select *
from bssapi.call_detail_records
where subscription_id = '116377120'
and year = 2020
and month = 3
and event_at = '2020-03-19 07:45:51+0000';