Просмотр исходного кода

feat(manual/trd): 订单补数范围收回 0716~0719(ODS 仅这几天残)

dump/rebucket 回到 0716~0719 子集(深 2026 未坏,不必全量重灌);
dump where 保持 create OR update >= '2026-07-16' 以兜住 update<create 脏单。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tianyu.chu 2 недель назад
Родитель
Сommit
7c750f4e90

+ 7 - 9
manual/backfill/20260721_ods_trd_card_group_order_info_backfill_rebucket.sql

@@ -1,17 +1,15 @@
 -- 作者:tianyu.chu
 -- 日期:2026-07-21
 -- 工单:(无)
--- 目的:一次性全 2026 重灌——读中转表 raw.tmp_trd_card_group_order_info(dt=20260721) 当前态全量,
---       每单按「活动日」落 ods 的整个 2026 分区(至 0719):
---         创建日一份(保证新建的单在 ful 完整,含 update<create 脏单)
---       + 变更日一份(保证创建更早、后来改过的单,其最新态能进 ful)。
---       一个 INSERT 覆盖 2026 各日,故每单用 explode 炸成 创建日/变更日 两行(同日只一份)。
---       取代 20260715 那版 COALESCE 2026 rebucket。
+-- 目的:一次性补数重灌——读中转表 raw.tmp_trd_card_group_order_info(dt=20260721) 当前态全量,
+--       每单按「活动日」落 ods 的 0716~0719 分区:
+--         创建日一份(保证这几天新建的单在 ful 完整,含 update<create 脏单)
+--       + 变更日一份(保证创建更早、这几天改过的单,其最新态能进 ful)。
+--       一个 INSERT 覆盖 0716~0719,故每单用 explode 炸成 创建日/变更日 两行(同日只一份)。
 -- 状态:[待执行]
 -- 备注:口径与 jobs/ods/trd/ods_trd_card_group_order_info_inc_d.sql 一致——explode 相当于把日常
 --         「按天各跑一次」的外层循环内联进一次 OVERWRITE(等价于跑四遍,省成一遍);
---       动态分区 OVERWRITE 只覆盖 SELECT 出现的 2026 各日(至 0719),不动 2025 及以前与 0720+(本环境默认 DYNAMIC);
---       act_dt 下界 2026-01-01:跨年单(2025 建、2026 改)的 2025 创建日份被挡,不碰 2025 历史;
+--       动态分区 OVERWRITE 只覆盖 SELECT 出现的 0716~0719,不动历史与 0720+(本环境默认 DYNAMIC);
 --       0720 交今天的日调度自愈,故 WHERE 封顶 0719;
 --       tmp 一单一行、创建日≠变更日 → (id,act_dt) 天然不重,无需去重;
 --       DISTRIBUTE BY act_dt 防每分区小文件(ADR-15);
@@ -128,5 +126,5 @@ FROM (
 LATERAL VIEW explode(
     CASE WHEN cdt = udt THEN array(cdt) ELSE array(cdt, udt) END   -- 同日一份;跨日炸成 创建日+变更日 两行
 ) e AS act_dt
-WHERE act_dt BETWEEN '20260101' AND '20260719'
+WHERE act_dt BETWEEN '20260716' AND '20260719'
 DISTRIBUTE BY dt;

+ 5 - 5
manual/backfill/20260721_tmp_trd_card_group_order_info_backfill_dump.ini

@@ -1,11 +1,11 @@
 ; 作者:tianyu.chu
 ; 日期:2026-07-21
 ; 工单:(无)
-; 目的:一次性全 2026 重灌——按 create OR update >= '2026-01-01' 拉当前态全量
+; 目的:一次性补数——按 create OR update >= '2026-07-16' 拉当前态全量
 ;       到中转表 raw.tmp_trd_card_group_order_info 单分区 dt=20260721,
-;       交给配套 rebucket 按「活动日(创建日∪变更日)」重灌 ods 的整个 2026(至 0719)
-;       取代 20260715 那版 COALESCE 2026 seed —— 后端确认存在 update<create 脏单,
-;       COALESCE 会把这类单甩到 <2026 窗外漏掉,改 create OR update 双命中兜住。
+;       交给配套 rebucket 按「活动日(创建日∪变更日)」重灌 ods 的 0716~0719 分区
+;       后端确认存在 update<create 脏单,COALESCE 会把这类单甩到 <0716 窗外漏掉,
+;       改 create OR update 双命中兜住(这正是之前 tmp 缺数的原因)
 ; 状态:[待执行]
 ;
 ; 配套 DDL:manual/ddl/raw/trd/tmp_trd_card_group_order_info_create.sql(若 tmp 已 drop 先建)
@@ -24,7 +24,7 @@ database = hobby_stocks
 table = public.card_group_order_info
 column = id,group_info_id,merchant_id,user_id,shipping_address_id,purchase_count,order_no,accounts_payable,actual_payment,payment_type,payment_time,coupon,discount,status,remark,create_time,create_by,update_time,update_by,payment_status,payment_status_desc,payment_success_time,del_flg,curier_company,refund_fee,refund_time,anonymous,pick_up_type,ship_time,refund_success_time,refund_recv_accout,refund_account,refund_request_source,card_price,act_price,goods_price_json,payment_sub_type,team_first,refuse_status,prop1,prop2,prop3,point,order_type,trade_amount,refund_type,refund_reason,evaluation,user_refund_time,refund_status,merchant_refund_reason,point_deduct,shipping_cost,merchant_remark,pay_record,order_sub_type,give_user_code,give_order_id,read_flag,give_num,invoice_id,combination_no,open_self,refund_desc,goods_allocate,close_payment_status,close_payment_time,finished_time,expire_time,settlement_amount,platform_coupon,platform_discount,discount_amount,member_discount,shipping_free_id,shipping_free_amount,discount_point,un_shipped_num,pre_un_shipped_num,wait_shipped_num,pre_wait_shipped_num,refuse_time,refuse_notice,pickup_time,waring_type,waring_status,point_type,delivery_end_time,serve_status,self_pickup_time,act_discount
 columnType =
-where = create_time >= '2026-01-01' OR update_time >= '2026-01-01'
+where = create_time >= '2026-07-16' OR update_time >= '2026-07-16'
 querySql =
 splitPk = id
 fetchSize = 1000