我在cassandra有一个巨大的orderhistory表,拥有2013年的数据,但我只想卸载最后12个月的有序历史数据,我使用下面的命令来完成它,从2013年开始卸载所有数据并存储在path data/json/customer_data/orderhistory/data中。如何修改下面的语句,以便每次运行该语句时,它都应该只选择最后12个月的数据?
dsbulk unload -k customer_data -t crawlsiteidentifiedpages -h '172.xx.xx.xxx' \
-c json -url data/json/customer_data/orderhistory/data发布于 2022-06-21 09:36:34
您需要删除选项-k和-t,并使用文档中描述的-query选项,如下所示:
dsbulk unload -query 'select * from ks.table where <your condition>'要确保卸载是并行化的,请确保您的条件包括类似于and token(pkcol) > :start and token(pkcol) <= :end的部分,其中pkcol是分区列的名称(如果您有多个分区列,请指定它们以逗号分隔)。
发布于 2022-06-21 09:54:24
您应该使用-t crawlsiteidentifiedpages而不是-query并提供SELECT查询,例如:
-query "SELECT * FROM crawlsiteidentifiedpages WHERE token(pk) > :start and token(pk) <= :end and date > maxTimeuuid('2021-06-21+0000') ALLOW FILTERING"几点意见:
pk和一个timeuuid类型的集群列date --请相应地调整实际查询。token(pk) > :start and token(pk) <= :end允许DSBulk并行操作并提高性能。date > maxTimeuuid('2021-06-21+0000')是魔术发生的地方,允许您只选择最后12个月的数据。ALLOW FILTERING添加到这种查询中,否则Cassandra将拒绝查询。https://stackoverflow.com/questions/72696818
复制相似问题