• doris手动添加分区自动消失的问题


    数据仓库开发指标时,需要回溯历史数据,对下面的表改为非动态表并添加更早时间的分区:

    1. -- 改为非动态分区
    2. ALTER TABLE test SET ("dynamic_partition.enable" = "false")
    3. -- 手动添加更早的时间分区
    4. ALTER TABLE test
    5. ADD PARTITION p20230912 VALUES [("2023-09-12"), ("2023-09-13"));
    6. --改为动态分区
    7. ALTER TABLE test SET ("dynamic_partition.enable" = "true")
    1. CREATE TABLE `test` (
    2. `id` bigint(20) NOT NULL COMMENT '主键',
    3. `dt` date NULL COMMENT '创建时间'
    4. ) ENGINE=OLAP
    5. DUPLICATE KEY(`id`)
    6. COMMENT 'olap'
    7. PARTITION BY RANGE(`dt`)
    8. PARTITION p20231010 VALUES [('2023-10-10'), ('2023-10-11')),
    9. PARTITION p20231011 VALUES [('2023-10-11'), ('2023-10-12')),
    10. PARTITION p20231012 VALUES [('2023-10-12'), ('2023-10-13')),
    11. PARTITION p20231013 VALUES [('2023-10-13'), ('2023-10-14')),
    12. PARTITION p20231014 VALUES [('2023-10-14'), ('2023-10-15')),
    13. PARTITION p20231015 VALUES [('2023-10-15'), ('2023-10-16')),
    14. PARTITION p20231016 VALUES [('2023-10-16'), ('2023-10-17')),
    15. PARTITION p20231017 VALUES [('2023-10-17'), ('2023-10-18')),
    16. PARTITION p20231018 VALUES [('2023-10-18'), ('2023-10-19')),
    17. PARTITION p20231019 VALUES [('2023-10-19'), ('2023-10-20')),
    18. PARTITION p20231020 VALUES [('2023-10-20'), ('2023-10-21')))
    19. DISTRIBUTED BY HASH(`id`) BUCKETS 10
    20. PROPERTIES (
    21. "replication_allocation" = "tag.location.default: 1",
    22. "dynamic_partition.enable" = "true",
    23. "dynamic_partition.time_unit" = "DAY",
    24. "dynamic_partition.time_zone" = "Asia/Shanghai",
    25. "dynamic_partition.start" = "-7",
    26. "dynamic_partition.end" = "3",
    27. "dynamic_partition.prefix" = "p",
    28. "dynamic_partition.replication_allocation" = "tag.location.default: 1",
    29. "dynamic_partition.buckets" = "10",
    30. "dynamic_partition.create_history_partition" = "false",
    31. "dynamic_partition.history_partition_num" = "-1",
    32. "dynamic_partition.hot_partition_num" = "0",
    33. "dynamic_partition.reserved_history_periods" = "NULL",
    34. "dynamic_partition.storage_policy" = "",
    35. "in_memory" = "false",
    36. "storage_format" = "V2",
    37. "disable_auto_compaction" = "false"
    38. );

    然而奇怪的事情发生了,创建的p20230912 不见了,后来考虑到可能是动态分区搞的鬼,是由于没有正确动态分区的属性 。

    看到表结构的”dynamic_partition.start” = “-7”,这表示
    动态分区的起始范围。表示从今天开始向前7天。 而
    p20230912 远远超过这个范围,后来把这个值调大后,果然不会凭空消失了。

    1. ALTER TABLE test SET
    2. ( "dynamic_partition.start" = "-75"
    3. );
  • 相关阅读:
    最新腾讯面试题汇总--C++后端开发岗(部分含答案)
    SpringBoot整合Mongodb
    SpringBoot自动配置原理
    gradle-2初始化篇(LoadSetings)
    MySQL主从复制与读写分离
    故障电弧探测器的必要性及组网方案 安科瑞 时丽花
    C. Rotation Matching
    Spring Security 实战 01 Security核心功能解析
    状态管理容器Pinia
    单片机——仿真软件Proteus基本使用教程
  • 原文地址:https://blog.csdn.net/linweidong/article/details/133915720