CREATE TABLE `yin_tmp` (
  `game_id` int NOT NULL,
  `role_id` varchar(64) NOT NULL,
  `ds` date NOT NULL,
  `server_id` int NULL,
  `user_account` varchar(50) NULL
) ENGINE = OLAP UNIQUE KEY(`game_id`, `role_id`, `ds`) PARTITION BY RANGE(`ds`) () DISTRIBUTED BY HASH(`game_id`) BUCKETS 32 PROPERTIES (
  "min_load_replica_num" = "-1", -- 不强制要求所有副本加载完成
  "dynamic_partition.enable" = "true", -- 开启动态分区功能。Doris 将根据后续规则自动管理分区生命周期
  "dynamic_partition.create_history_partition" = "true", -- 自动创建历史分区
  "dynamic_partition.time_unit" = "DAY", -- 分区粒度按天划分
  "dynamic_partition.time_zone" = "Asia/Shanghai", -- 指定分区生成的时区
  "dynamic_partition.start" = "-185", -- 保留最近 185 天的分区
  "dynamic_partition.end" = "3", -- 预创建未来 3 天的分区
  "dynamic_partition.prefix" = "p_", -- 分区名前缀。
  "storage_medium" = "hdd", -- 存储策略
  "dynamic_partition.hot_partition_num" = "7"   -- 最近7天分区存SSD
);

SHOW PARTITIONS FROM yin_tmp;


insert into yin_tmp (game_id, role_id, ds, server_id, user_account)
select '1' game_id,'1' role_id,STR_TO_DATE('20250626','%Y%m%d') ds,1 server_id,'1' user_account


show load warnings on 'http://10.0.8.10:8040/api/_load_error_log?file=__shard_740/error_log_insert_stmt_2fac3a52b4c74b34-b59367b2b7ec133c_2fac3a52b4c74b34_b59367b2b7ec133c'


drop table monthly_sales;

CREATE TABLE `dwd_platform_login_m` (
    `game_id` int NOT NULL,
  `user_id` bigint NOT NULL,
  `ds` date NULL,
  `user_account` varchar(100) NULL,
  `promote_id` int NULL,
  `platform_id` int NULL,
  `login_time` int NOT NULL,
  `login_ip` varchar(50) NULL
)
ENGINE = OLAP  DUPLICATE KEY(`game_id`, `user_id`, `ds`)
PARTITION BY RANGE(`ds`) ()
DISTRIBUTED BY HASH(`game_id`) BUCKETS 32
PROPERTIES (
    "min_load_replica_num" = "-1",
  "dynamic_partition.enable" = "true",
  "dynamic_partition.time_unit" = "MONTH",
  "dynamic_partition.time_zone" = "Asia/Shanghai",
  "dynamic_partition.start" = "-24",
  "dynamic_partition.end" = "3",
  "dynamic_partition.buckets" = "32",
  "dynamic_partition.create_history_partition" = "true",
  "dynamic_partition.prefix" = "p_",
  "storage_medium" = "hdd"
);


CREATE TABLE `dwd_retention_act` (
  `game_id` int NOT NULL,
  `user_id` bigint NOT NULL,
  `ds` date NULL,
  `rd` int NULL
) ENGINE = OLAP DUPLICATE KEY(`game_id`, `user_id`, `ds`,rd) PARTITION BY RANGE(`ds`) () DISTRIBUTED BY HASH(ds,`game_id`) BUCKETS 32 PROPERTIES (
    "min_load_replica_num" = "-1",
  "dynamic_partition.enable" = "true",
  "dynamic_partition.time_unit" = "DAY",
  "dynamic_partition.time_zone" = "Asia/Shanghai",
  "dynamic_partition.start" = "-24",
  "dynamic_partition.end" = "3",
  "dynamic_partition.buckets" = "32",
  "dynamic_partition.create_history_partition" = "true",
  "dynamic_partition.prefix" = "p_",
  "storage_medium" = "hdd"
);