[英]How to include SQL select statement in dsbulk unload command
我在 cassandra 中有一个巨大的 orderhistory 表,其中包含 2013 年的数据,但我只想卸载最后 12 个月的 orderhistory 数据,我使用下面的命令来卸载从 2013 年开始的所有数据并存储在路径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
您需要删除选项-k
和-t
,而是使用文档中描述的-query
选项,例如:
dsbulk unload -query 'select * from ks.table where <your condition>'
为确保卸载是并行化的,请确保您的条件包括像and token(pkcol) > :start and token(pkcol) <= :end
这样的部分,其中pkcol
是分区列的名称(如果您有多个分区列,指定它们以逗号分隔)。
而不是-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 将拒绝该查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.