clickhouse重复导数问题

背景

因为使用alter table … drop (del)等情况都是在异步执行的,所以我们在导数的时候一定会考虑重复导数,补数等情况

分区表

1.先把导数的分区下掉
alter table [table] detach partition ‘xxx’;
2.把数据导入表中
2.1 alter table [table] move partition ‘xxx’ to table [table]
2.2 直接写
两种方式任选一种
3.删除下掉的数据
alter table [xxx] drop detached partition ‘xxx’

ps:可能报错allow_drop_detached
解决:https://stackoverflow.com/questions/61950278/how-to-enable-allow-drop-detached-in-system-settings
/etc/clickhouse-server/users.d/query.settings.xml

<?xml version="1.0"?>
<yandex>
    <profiles>
        <default>
            <!-- Allow ALTER TABLE ... DROP DETACHED PART[ITION] ... queries. -->
            <allow_drop_detached>1</allow_drop_detached>
        </default>
    </profiles>
</yandex>

非分区表

直接truncate然后轮询的查询,没有数据时再导入

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值