Эх сурвалжийг харах

feat(ods): 加 ods 同步 SQL × 8 + 订单表 his_o 初始化 SQL(ADR-03 双源 union 落地)

按 ADR-03 双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt}
过滤 + (id, ods_dt) dedupe + 动态分区落 8 个调度 SQL;订单表独立一份 his_o
+ inc_d 全量历史灌入 SQL 走 manual/backfill/。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tianyu.chu 14 цаг өмнө
parent
commit
5557a670a1

+ 59 - 0
jobs/ods/prd/ods_prd_checklist_base_info_inc_d.sql

@@ -0,0 +1,59 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2
+
+INSERT OVERWRITE TABLE ods.ods_prd_checklist_base_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id                AS BIGINT)    AS id,
+    code                                 AS code,
+    year                                 AS year,
+    sport                                AS sport,
+    manufacturer                         AS manufacturer,
+    sets                                 AS sets,
+    display_name                         AS display_name,
+    type                                 AS type,
+    CAST(num               AS BIGINT)    AS num,
+    CAST(use_num           AS BIGINT)    AS use_num,
+    CAST(status            AS BIGINT)    AS status,
+    remark                               AS remark,
+    CAST(create_time       AS TIMESTAMP) AS create_time,
+    create_by                            AS create_by,
+    CAST(update_time       AS TIMESTAMP) AS update_time,
+    update_by                            AS update_by,
+    CAST(lot               AS BIGINT)    AS lot,
+    CAST(del_flg           AS BIGINT)    AS del_flg,
+    act_point_type                       AS act_point_type,
+    CAST(parent_id         AS BIGINT)    AS parent_id,
+    sets_version                         AS sets_version,
+    CAST(merchant_id       AS BIGINT)    AS merchant_id,
+    merchant_name                        AS merchant_name,
+    CAST(share             AS BIGINT)    AS share,
+    share_to_merchant                    AS share_to_merchant,
+    CAST(custom            AS BIGINT)    AS custom,
+    CAST(panini_config_id  AS BIGINT)    AS panini_config_id,
+    import_failure_cause                 AS import_failure_cause,
+    check_failure_cause                  AS check_failure_cause,
+    CAST(import_status     AS BIGINT)    AS import_status,
+    review_msg                           AS review_msg,
+    sub_type                             AS sub_type,
+    title                                AS title,
+    data_version                         AS data_version,
+    CAST(sport_blend       AS BIGINT)    AS sport_blend,
+    display_name_translations            AS display_name_translations,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                               AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_prd_checklist_base_info_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 56 - 0
jobs/ods/prd/ods_prd_panini_checklist_base_info_inc_d.sql

@@ -0,0 +1,56 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2
+
+INSERT OVERWRITE TABLE ods.ods_prd_panini_checklist_base_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id                 AS BIGINT)        AS id,
+    code                                      AS code,
+    year                                      AS year,
+    sport                                     AS sport,
+    manufacturer                              AS manufacturer,
+    sets                                      AS sets,
+    sets_version                              AS sets_version,
+    display_name                              AS display_name,
+    type                                      AS type,
+    CAST(num                AS BIGINT)        AS num,
+    CAST(use_num            AS BIGINT)        AS use_num,
+    CAST(status             AS BIGINT)        AS status,
+    remark                                    AS remark,
+    CAST(lot                AS BIGINT)        AS lot,
+    CAST(del_flg            AS BIGINT)        AS del_flg,
+    carmichael_img_type                       AS carmichael_img_type,
+    CAST(create_time        AS TIMESTAMP)     AS create_time,
+    create_by                                 AS create_by,
+    CAST(update_time        AS TIMESTAMP)     AS update_time,
+    update_by                                 AS update_by,
+    import_type                               AS import_type,
+    CAST(report_flag        AS BIGINT)        AS report_flag,
+    base_config                               AS base_config,
+    CAST(base_price         AS DECIMAL(20,4)) AS base_price,
+    CAST(min_reference_price AS DECIMAL(20,4)) AS min_reference_price,
+    CAST(max_reference_price AS DECIMAL(20,4)) AS max_reference_price,
+    prop1                                     AS prop1,
+    prop2                                     AS prop2,
+    prop3                                     AS prop3,
+    prop4                                     AS prop4,
+    data_version                              AS data_version,
+    first_sport                               AS first_sport,
+    sets_display_name                         AS sets_display_name,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                                    AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_prd_panini_checklist_base_info_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 56 - 0
jobs/ods/prd/ods_prd_panini_checklist_version_config_inc_d.sql

@@ -0,0 +1,56 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2
+
+INSERT OVERWRITE TABLE ods.ods_prd_panini_checklist_version_config_inc_d PARTITION (dt)
+SELECT
+    CAST(id                  AS BIGINT)        AS id,
+    CAST(panini_list_id      AS BIGINT)        AS panini_list_id,
+    set_version                                AS set_version,
+    carmichael_img_type                        AS carmichael_img_type,
+    import_type                                AS import_type,
+    CAST(report_flag         AS BIGINT)        AS report_flag,
+    base_config                                AS base_config,
+    CAST(base_price          AS DECIMAL(20,4)) AS base_price,
+    CAST(min_reference_price AS DECIMAL(20,4)) AS min_reference_price,
+    CAST(max_reference_price AS DECIMAL(20,4)) AS max_reference_price,
+    CAST(num                 AS BIGINT)        AS num,
+    CAST(use_num             AS BIGINT)        AS use_num,
+    CAST(status              AS BIGINT)        AS status,
+    remark                                     AS remark,
+    CAST(del_flg             AS BIGINT)        AS del_flg,
+    CAST(create_time         AS TIMESTAMP)     AS create_time,
+    create_by                                  AS create_by,
+    CAST(update_time         AS TIMESTAMP)     AS update_time,
+    update_by                                  AS update_by,
+    prop1                                      AS prop1,
+    prop2                                      AS prop2,
+    prop3                                      AS prop3,
+    prop4                                      AS prop4,
+    tag                                        AS tag,
+    display_name                               AS display_name,
+    CAST(presale_time        AS TIMESTAMP)     AS presale_time,
+    CAST(max_box             AS BIGINT)        AS max_box,
+    league                                     AS league,
+    CAST(issuing_time        AS TIMESTAMP)     AS issuing_time,
+    CAST(issuing_price       AS DECIMAL(20,4)) AS issuing_price,
+    display_name_translations                  AS display_name_translations,
+    CAST(sale_time           AS TIMESTAMP)     AS sale_time,
+    CAST(open_time           AS BIGINT)        AS open_time,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                                     AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_prd_panini_checklist_version_config_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 73 - 0
jobs/ods/shp/ods_shp_tzy_merchant_info_inc_d.sql

@@ -0,0 +1,73 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2
+
+INSERT OVERWRITE TABLE ods.ods_shp_tzy_merchant_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id                  AS BIGINT)    AS id,
+    appid                                  AS appid,
+    CAST(user_id             AS BIGINT)    AS user_id,
+    username                               AS username,
+    name                                   AS name,
+    CAST(status              AS BIGINT)    AS status,
+    remark                                 AS remark,
+    create_by                              AS create_by,
+    CAST(create_time         AS TIMESTAMP) AS create_time,
+    update_by                              AS update_by,
+    CAST(update_time         AS TIMESTAMP) AS update_time,
+    code                                   AS code,
+    CAST(fans                AS BIGINT)    AS fans,
+    CAST(sale_num            AS BIGINT)    AS sale_num,
+    CAST(applet_auth         AS BOOLEAN)   AS applet_auth,
+    CAST(applet_lives_auth   AS BOOLEAN)   AS applet_lives_auth,
+    applet_lives_role                      AS applet_lives_role,
+    commission_rate                        AS commission_rate,
+    prop_json                              AS prop_json,
+    CAST(sort_rate           AS BIGINT)    AS sort_rate,
+    CAST(check_status        AS BIGINT)    AS check_status,
+    live_type                              AS live_type,
+    living_auth_config                     AS living_auth_config,
+    CAST(goods_sold_num      AS BIGINT)    AS goods_sold_num,
+    hot_config                             AS hot_config,
+    tag_config                             AS tag_config,
+    CAST(mall_role           AS BIGINT)    AS mall_role,
+    living_time                            AS living_time,
+    express_level                          AS express_level,
+    CAST(del_flg             AS BIGINT)    AS del_flg,
+    group_show_name                        AS group_show_name,
+    main_business                          AS main_business,
+    CAST(min_card_num        AS BIGINT)    AS min_card_num,
+    dy_name                                AS dy_name,
+    CAST(current_month_score AS DOUBLE)    AS current_month_score,
+    CAST(member_level        AS BIGINT)    AS member_level,
+    member_name                            AS member_name,
+    member_medal                           AS member_medal,
+    CAST(prefer_valid_time   AS TIMESTAMP) AS prefer_valid_time,
+    tag_id                                 AS tag_id,
+    CAST(show_status         AS BIGINT)    AS show_status,
+    point_type                             AS point_type,
+    CAST(refund_limit_day    AS BIGINT)    AS refund_limit_day,
+    CAST(open_act_discount   AS BIGINT)    AS open_act_discount,
+    CAST(reputation_score    AS BIGINT)    AS reputation_score,
+    CAST(hide_stock          AS BIGINT)    AS hide_stock,
+    CAST(version             AS BIGINT)    AS version,
+    CAST(total_sold_num      AS BIGINT)    AS total_sold_num,
+    shipping_cost_config                   AS shipping_cost_config,
+    CAST(merchant_group_id   AS BIGINT)    AS merchant_group_id,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                                 AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_shp_tzy_merchant_info_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 138 - 0
jobs/ods/trd/ods_trd_card_group_info_inc_d.sql

@@ -0,0 +1,138 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2;ods 跨 dt 不去重,同 pk 多 dt 并存(拉链表底层)
+
+INSERT OVERWRITE TABLE ods.ods_trd_card_group_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id                           AS BIGINT)        AS id,
+    CAST(merchant_id                  AS BIGINT)        AS merchant_id,
+    appid                                               AS appid,
+    name                                                AS name,
+    code                                                AS code,
+    CAST(status                       AS BIGINT)        AS status,
+    specs                                               AS specs,
+    type                                                AS type,
+    random_type                                         AS random_type,
+    CAST(total_price                  AS DECIMAL(20,4)) AS total_price,
+    CAST(copies                       AS BIGINT)        AS copies,
+    CAST(unit_price                   AS DECIMAL(20,4)) AS unit_price,
+    CAST(sold_copies                  AS BIGINT)        AS sold_copies,
+    release_time                                        AS release_time,
+    cycle                                               AS cycle,
+    show_applet                                         AS show_applet,
+    title                                               AS title,
+    msg                                                 AS msg,
+    remark                                              AS remark,
+    CAST(create_time                  AS TIMESTAMP)     AS create_time,
+    update_by                                           AS update_by,
+    CAST(update_time                  AS TIMESTAMP)     AS update_time,
+    CAST(order_quota_min              AS BIGINT)        AS order_quota_min,
+    CAST(order_quota_max              AS BIGINT)        AS order_quota_max,
+    CAST(user_quota_max               AS BIGINT)        AS user_quota_max,
+    CAST(start_time                   AS TIMESTAMP)     AS start_time,
+    marketing_info                                      AS marketing_info,
+    reviewmsg                                           AS reviewmsg,
+    CAST(`lock`                       AS BOOLEAN)       AS `lock`,
+    commission_rate                                     AS commission_rate,
+    year                                                AS year,
+    sport                                               AS sport,
+    manufacturer                                        AS manufacturer,
+    sets                                                AS sets,
+    act                                                 AS act,
+    config                                              AS config,
+    info_config                                         AS info_config,
+    CAST(total_num                    AS BIGINT)        AS total_num,
+    CAST(banner_end_time              AS TIMESTAMP)     AS banner_end_time,
+    add_banner                                          AS add_banner,
+    CAST(finished_time                AS TIMESTAMP)     AS finished_time,
+    display_name                                        AS display_name,
+    CAST(group_sets_no                AS BIGINT)        AS group_sets_no,
+    CAST(close_payment_time           AS TIMESTAMP)     AS close_payment_time,
+    CAST(confirm_send_time            AS TIMESTAMP)     AS confirm_send_time,
+    CAST(close_payment_status         AS BIGINT)        AS close_payment_status,
+    CAST(open_card                    AS BIGINT)        AS open_card,
+    close_payment_record                                AS close_payment_record,
+    CAST(group_full_time              AS TIMESTAMP)     AS group_full_time,
+    CAST(live_create_time             AS TIMESTAMP)     AS live_create_time,
+    CAST(live_start_time              AS TIMESTAMP)     AS live_start_time,
+    CAST(live_end_time                AS TIMESTAMP)     AS live_end_time,
+    CAST(report_start_time            AS TIMESTAMP)     AS report_start_time,
+    CAST(report_end_time              AS TIMESTAMP)     AS report_end_time,
+    CAST(report_review_num            AS BIGINT)        AS report_review_num,
+    CAST(report_review_first_time     AS TIMESTAMP)     AS report_review_first_time,
+    CAST(report_review_end_time       AS TIMESTAMP)     AS report_review_end_time,
+    CAST(review_hold_time             AS TIMESTAMP)     AS review_hold_time,
+    CAST(review_approval_time         AS TIMESTAMP)     AS review_approval_time,
+    CAST(review_num                   AS BIGINT)        AS review_num,
+    config_json                                         AS config_json,
+    CAST(free_flag                    AS BIGINT)        AS free_flag,
+    mer_name                                            AS mer_name,
+    change_type                                         AS change_type,
+    CAST(act_price                    AS DECIMAL(20,4)) AS act_price,
+    act_config_json                                     AS act_config_json,
+    CAST(real_sold_num                AS BIGINT)        AS real_sold_num,
+    CAST(weight                       AS BIGINT)        AS weight,
+    hot_type                                            AS hot_type,
+    CAST(team_first                   AS BIGINT)        AS team_first,
+    prop1                                               AS prop1,
+    prop2                                               AS prop2,
+    prop3                                               AS prop3,
+    CAST(point_rate                   AS BIGINT)        AS point_rate,
+    CAST(point_max                    AS BIGINT)        AS point_max,
+    CAST(point_min                    AS BIGINT)        AS point_min,
+    CAST(list_id                      AS BIGINT)        AS list_id,
+    list_code                                           AS list_code,
+    CAST(mix_copies                   AS BIGINT)        AS mix_copies,
+    sub_type                                            AS sub_type,
+    act_point_type                                      AS act_point_type,
+    CAST(payment_method               AS BIGINT)        AS payment_method,
+    CAST(payment_total_price          AS DECIMAL(20,4)) AS payment_total_price,
+    CAST(payment_commission           AS DECIMAL(20,4)) AS payment_commission,
+    CAST(payment_finished_price       AS DECIMAL(20,4)) AS payment_finished_price,
+    CAST(payment_remain_price         AS DECIMAL(20,4)) AS payment_remain_price,
+    CAST(payment_online_price         AS DECIMAL(20,4)) AS payment_online_price,
+    CAST(exclusive                    AS BIGINT)        AS exclusive,
+    CAST(has_bg                       AS BIGINT)        AS has_bg,
+    CAST(merchant_sort                AS BIGINT)        AS merchant_sort,
+    CAST(del_flg                      AS BIGINT)        AS del_flg,
+    CAST(del_time                     AS TIMESTAMP)     AS del_time,
+    review_account                                      AS review_account,
+    CAST(act_id                       AS BIGINT)        AS act_id,
+    CAST(sold_end_time                AS TIMESTAMP)     AS sold_end_time,
+    CAST(panini_list_id               AS BIGINT)        AS panini_list_id,
+    hot_type_config                                     AS hot_type_config,
+    CAST(goods_type                   AS BIGINT)        AS goods_type,
+    CAST(report_flag                  AS BIGINT)        AS report_flag,
+    CAST(use_coupon                   AS BIGINT)        AS use_coupon,
+    CAST(user_level                   AS BIGINT)        AS user_level,
+    CAST(custom                       AS BIGINT)        AS custom,
+    CAST(gift_card_id                 AS BIGINT)        AS gift_card_id,
+    group_show_name                                     AS group_show_name,
+    CAST(min_card_num                 AS BIGINT)        AS min_card_num,
+    act_type                                            AS act_type,
+    waring_type                                         AS waring_type,
+    CAST(compensation_status          AS BIGINT)        AS compensation_status,
+    point_type                                          AS point_type,
+    first_act_config                                    AS first_act_config,
+    gift_config                                         AS gift_config,
+    CAST(version                      AS BIGINT)        AS version,
+    extra_prop                                          AS extra_prop,
+    CAST(use_member_discount          AS BIGINT)        AS use_member_discount,
+    CAST(merchant_open                AS BIGINT)        AS merchant_open,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END    AS is_deleted,
+    ods_dt                                              AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_trd_card_group_info_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 115 - 0
jobs/ods/trd/ods_trd_card_group_order_info_inc_d.sql

@@ -0,0 +1,115 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2;ods 跨 dt 不去重,同 pk 多 dt 并存(拉链表底层);
+--       订单表 his_o 历史灌入由 manual/backfill/ods_trd_card_group_order_info_init.sql 一次性处理,本调度只读 inc_d
+
+INSERT OVERWRITE TABLE ods.ods_trd_card_group_order_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id                        AS BIGINT)        AS id,
+    CAST(group_info_id             AS BIGINT)        AS group_info_id,
+    CAST(merchant_id               AS BIGINT)        AS merchant_id,
+    CAST(user_id                   AS BIGINT)        AS user_id,
+    CAST(shipping_address_id       AS BIGINT)        AS shipping_address_id,
+    CAST(purchase_count            AS BIGINT)        AS purchase_count,
+    order_no                                         AS order_no,
+    CAST(accounts_payable          AS DECIMAL(20,4)) AS accounts_payable,
+    CAST(actual_payment            AS DECIMAL(20,4)) AS actual_payment,
+    payment_type                                     AS payment_type,
+    CAST(payment_time              AS TIMESTAMP)     AS payment_time,
+    CAST(coupon                    AS BIGINT)        AS coupon,
+    CAST(discount                  AS DECIMAL(20,4)) AS discount,
+    CAST(status                    AS BIGINT)        AS status,
+    remark                                           AS remark,
+    CAST(create_time               AS TIMESTAMP)     AS create_time,
+    create_by                                        AS create_by,
+    CAST(update_time               AS TIMESTAMP)     AS update_time,
+    update_by                                        AS update_by,
+    payment_status                                   AS payment_status,
+    payment_status_desc                              AS payment_status_desc,
+    CAST(payment_success_time      AS TIMESTAMP)     AS payment_success_time,
+    CAST(del_flg                   AS BIGINT)        AS del_flg,
+    curier_company                                   AS curier_company,
+    CAST(refund_fee                AS DECIMAL(20,4)) AS refund_fee,
+    CAST(refund_time               AS TIMESTAMP)     AS refund_time,
+    CAST(anonymous                 AS BOOLEAN)       AS anonymous,
+    pick_up_type                                     AS pick_up_type,
+    CAST(ship_time                 AS TIMESTAMP)     AS ship_time,
+    CAST(refund_success_time       AS TIMESTAMP)     AS refund_success_time,
+    refund_recv_accout                               AS refund_recv_accout,
+    refund_account                                   AS refund_account,
+    refund_request_source                            AS refund_request_source,
+    CAST(card_price                AS DECIMAL(20,4)) AS card_price,
+    CAST(act_price                 AS DECIMAL(20,4)) AS act_price,
+    goods_price_json                                 AS goods_price_json,
+    payment_sub_type                                 AS payment_sub_type,
+    team_first                                       AS team_first,
+    CAST(refuse_status             AS BIGINT)        AS refuse_status,
+    prop1                                            AS prop1,
+    prop2                                            AS prop2,
+    prop3                                            AS prop3,
+    CAST(point                     AS BIGINT)        AS point,
+    order_type                                       AS order_type,
+    CAST(trade_amount              AS DECIMAL(20,4)) AS trade_amount,
+    refund_type                                      AS refund_type,
+    refund_reason                                    AS refund_reason,
+    evaluation                                       AS evaluation,
+    CAST(user_refund_time          AS TIMESTAMP)     AS user_refund_time,
+    CAST(refund_status             AS BIGINT)        AS refund_status,
+    merchant_refund_reason                           AS merchant_refund_reason,
+    CAST(point_deduct              AS DECIMAL(20,4)) AS point_deduct,
+    CAST(shipping_cost             AS DECIMAL(20,4)) AS shipping_cost,
+    merchant_remark                                  AS merchant_remark,
+    CAST(pay_record                AS BIGINT)        AS pay_record,
+    order_sub_type                                   AS order_sub_type,
+    give_user_code                                   AS give_user_code,
+    CAST(give_order_id             AS BIGINT)        AS give_order_id,
+    CAST(read_flag                 AS BIGINT)        AS read_flag,
+    CAST(give_num                  AS BIGINT)        AS give_num,
+    CAST(invoice_id                AS BIGINT)        AS invoice_id,
+    combination_no                                   AS combination_no,
+    CAST(open_self                 AS BIGINT)        AS open_self,
+    refund_desc                                      AS refund_desc,
+    CAST(goods_allocate            AS BIGINT)        AS goods_allocate,
+    CAST(close_payment_status      AS BIGINT)        AS close_payment_status,
+    CAST(close_payment_time        AS TIMESTAMP)     AS close_payment_time,
+    CAST(finished_time             AS TIMESTAMP)     AS finished_time,
+    CAST(expire_time               AS TIMESTAMP)     AS expire_time,
+    CAST(settlement_amount         AS DECIMAL(20,4)) AS settlement_amount,
+    CAST(platform_coupon           AS BIGINT)        AS platform_coupon,
+    CAST(platform_discount         AS DECIMAL(20,4)) AS platform_discount,
+    CAST(discount_amount           AS DECIMAL(20,4)) AS discount_amount,
+    CAST(member_discount           AS DECIMAL(20,4)) AS member_discount,
+    CAST(shipping_free_id          AS BIGINT)        AS shipping_free_id,
+    CAST(shipping_free_amount      AS DECIMAL(20,4)) AS shipping_free_amount,
+    CAST(discount_point            AS BIGINT)        AS discount_point,
+    CAST(un_shipped_num            AS BIGINT)        AS un_shipped_num,
+    CAST(pre_un_shipped_num        AS BIGINT)        AS pre_un_shipped_num,
+    CAST(wait_shipped_num          AS BIGINT)        AS wait_shipped_num,
+    CAST(pre_wait_shipped_num      AS BIGINT)        AS pre_wait_shipped_num,
+    CAST(refuse_time               AS TIMESTAMP)     AS refuse_time,
+    CAST(refuse_notice             AS BIGINT)        AS refuse_notice,
+    CAST(pickup_time               AS TIMESTAMP)     AS pickup_time,
+    waring_type                                      AS waring_type,
+    CAST(waring_status             AS BIGINT)        AS waring_status,
+    point_type                                       AS point_type,
+    CAST(delivery_end_time         AS TIMESTAMP)     AS delivery_end_time,
+    CAST(serve_status              AS BIGINT)        AS serve_status,
+    CAST(self_pickup_time          AS TIMESTAMP)     AS self_pickup_time,
+    CAST(act_discount              AS DECIMAL(20,4)) AS act_discount,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                                           AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_trd_card_group_order_info_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 75 - 0
jobs/ods/usr/ods_usr_app_base_user_inc_d.sql

@@ -0,0 +1,75 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2;ods 跨 dt 不去重,同 pk 多 dt 并存(拉链表底层)
+
+INSERT OVERWRITE TABLE ods.ods_usr_app_base_user_inc_d PARTITION (dt)
+SELECT
+    CAST(id                       AS BIGINT)        AS id,
+    appid                                           AS appid,
+    CAST(point                    AS BIGINT)        AS point,
+    CAST(level                    AS BIGINT)        AS level,
+    register_channel                                AS register_channel,
+    CAST(status                   AS BIGINT)        AS status,
+    CAST(del_flg                  AS BIGINT)        AS del_flg,
+    remark                                          AS remark,
+    create_by                                       AS create_by,
+    CAST(create_time              AS TIMESTAMP)     AS create_time,
+    update_by                                       AS update_by,
+    CAST(update_time              AS TIMESTAMP)     AS update_time,
+    username                                        AS username,
+    CAST(growth_num               AS BIGINT)        AS growth_num,
+    code                                            AS code,
+    CAST(notify_flag              AS BIGINT)        AS notify_flag,
+    CAST(user_id                  AS BIGINT)        AS user_id,
+    notify_type                                     AS notify_type,
+    CAST(face_verify              AS BIGINT)        AS face_verify,
+    CAST(open_psd                 AS BIGINT)        AS open_psd,
+    CAST(refuse_pick_up           AS BIGINT)        AS refuse_pick_up,
+    prop1                                           AS prop1,
+    prop2                                           AS prop2,
+    prop3                                           AS prop3,
+    prop4                                           AS prop4,
+    CAST(window_open              AS BIGINT)        AS window_open,
+    CAST(open_invoice             AS BIGINT)        AS open_invoice,
+    CAST(blacklist                AS BIGINT)        AS blacklist,
+    id_card                                         AS id_card,
+    CAST(member_level             AS BIGINT)        AS member_level,
+    member_name                                     AS member_name,
+    CAST(current_month_growth     AS BIGINT)        AS current_month_growth,
+    CAST(member_init_flag         AS BIGINT)        AS member_init_flag,
+    CAST(member_keep_growth       AS BIGINT)        AS member_keep_growth,
+    register_ip_addr                                AS register_ip_addr,
+    register_addr                                   AS register_addr,
+    login_ip_addr                                   AS login_ip_addr,
+    login_addr                                      AS login_addr,
+    CAST(notify_top_show          AS BIGINT)        AS notify_top_show,
+    CAST(voice_reminder           AS BIGINT)        AS voice_reminder,
+    CAST(vibrate_reminder         AS BIGINT)        AS vibrate_reminder,
+    CAST(consume_amount           AS DECIMAL(20,4)) AS consume_amount,
+    CAST(order_total_num          AS BIGINT)        AS order_total_num,
+    CAST(open_card_show           AS BIGINT)        AS open_card_show,
+    effects_type                                    AS effects_type,
+    live_config_json                                AS live_config_json,
+    CAST(cancel_verify_num        AS BIGINT)        AS cancel_verify_num,
+    CAST(version                  AS BIGINT)        AS version,
+    CAST(daily_limit              AS BIGINT)        AS daily_limit,
+    CAST(weekly_limit             AS BIGINT)        AS weekly_limit,
+    CAST(monthly_limit            AS BIGINT)        AS monthly_limit,
+    CAST(live_anonymous           AS BIGINT)        AS live_anonymous,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                                          AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_usr_app_base_user_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 34 - 0
jobs/ods/usr/ods_usr_app_user_cert_info_inc_d.sql

@@ -0,0 +1,34 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:raw → ods 增量同步(ADR-03);双源 union (raw dt=${dt} + raw dt=${pdt}) + DATE_FORMAT(update_time)=${dt} 过滤 + (id, ods_dt) dedupe + 动态分区写入
+-- 状态:[草案]
+-- 备注:sched=T,${dt}=业务日 T-1(yyyyMMdd),${pdt}=T-2;本表软删字段为 del_flag(其它表多为 del_flg)
+
+INSERT OVERWRITE TABLE ods.ods_usr_app_user_cert_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id            AS BIGINT)    AS id,
+    CAST(user_id       AS BIGINT)    AS user_id,
+    CAST(cert_birthday AS TIMESTAMP) AS cert_birthday,
+    CAST(cert_sex      AS BIGINT)    AS cert_sex,
+    cert_province                    AS cert_province,
+    cert_city                        AS cert_city,
+    CAST(version       AS BIGINT)    AS version,
+    CAST(status        AS BIGINT)    AS status,
+    CAST(del_flag      AS BIGINT)    AS del_flag,
+    CAST(create_time   AS TIMESTAMP) AS create_time,
+    CAST(update_time   AS TIMESTAMP) AS update_time,
+    CASE WHEN del_flag = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                           AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM raw.raw_usr_app_user_cert_info_inc_d
+    WHERE dt IN ('${dt}', '${pdt}')
+      AND DATE_FORMAT(update_time, 'yyyyMMdd') = '${dt}'
+) t
+WHERE t.rn = 1;

+ 153 - 0
manual/backfill/ods_trd_card_group_order_info_init.sql

@@ -0,0 +1,153 @@
+-- 作者:tianyu.chu
+-- 日期:2026-05-07
+-- 工单:(无)
+-- 目的:订单表 ods 初始化一次性灌入:raw_his_o(存量历史)+ raw_inc_d(已跑全部增量)UNION ALL,
+--       按 DATE_FORMAT(update_time, 'yyyyMMdd') 归位到 ods 各 dt 分区,(id, ods_dt) dedupe,动态分区写入
+-- 状态:[待执行]
+-- 备注:跑一次后由 jobs/ods/trd/ods_trd_card_group_order_info_inc_d.sql 接管日常增量;
+--       his_o + inc_d schema 完全一致(91 字段 STRING),SELECT * UNION ALL 安全;
+--       update_time 为空的行落入 __HIVE_DEFAULT_PARTITION__(非阻塞,下游自行处理)
+
+INSERT OVERWRITE TABLE ods.ods_trd_card_group_order_info_inc_d PARTITION (dt)
+SELECT
+    CAST(id                        AS BIGINT)        AS id,
+    CAST(group_info_id             AS BIGINT)        AS group_info_id,
+    CAST(merchant_id               AS BIGINT)        AS merchant_id,
+    CAST(user_id                   AS BIGINT)        AS user_id,
+    CAST(shipping_address_id       AS BIGINT)        AS shipping_address_id,
+    CAST(purchase_count            AS BIGINT)        AS purchase_count,
+    order_no                                         AS order_no,
+    CAST(accounts_payable          AS DECIMAL(20,4)) AS accounts_payable,
+    CAST(actual_payment            AS DECIMAL(20,4)) AS actual_payment,
+    payment_type                                     AS payment_type,
+    CAST(payment_time              AS TIMESTAMP)     AS payment_time,
+    CAST(coupon                    AS BIGINT)        AS coupon,
+    CAST(discount                  AS DECIMAL(20,4)) AS discount,
+    CAST(status                    AS BIGINT)        AS status,
+    remark                                           AS remark,
+    CAST(create_time               AS TIMESTAMP)     AS create_time,
+    create_by                                        AS create_by,
+    CAST(update_time               AS TIMESTAMP)     AS update_time,
+    update_by                                        AS update_by,
+    payment_status                                   AS payment_status,
+    payment_status_desc                              AS payment_status_desc,
+    CAST(payment_success_time      AS TIMESTAMP)     AS payment_success_time,
+    CAST(del_flg                   AS BIGINT)        AS del_flg,
+    curier_company                                   AS curier_company,
+    CAST(refund_fee                AS DECIMAL(20,4)) AS refund_fee,
+    CAST(refund_time               AS TIMESTAMP)     AS refund_time,
+    CAST(anonymous                 AS BOOLEAN)       AS anonymous,
+    pick_up_type                                     AS pick_up_type,
+    CAST(ship_time                 AS TIMESTAMP)     AS ship_time,
+    CAST(refund_success_time       AS TIMESTAMP)     AS refund_success_time,
+    refund_recv_accout                               AS refund_recv_accout,
+    refund_account                                   AS refund_account,
+    refund_request_source                            AS refund_request_source,
+    CAST(card_price                AS DECIMAL(20,4)) AS card_price,
+    CAST(act_price                 AS DECIMAL(20,4)) AS act_price,
+    goods_price_json                                 AS goods_price_json,
+    payment_sub_type                                 AS payment_sub_type,
+    team_first                                       AS team_first,
+    CAST(refuse_status             AS BIGINT)        AS refuse_status,
+    prop1                                            AS prop1,
+    prop2                                            AS prop2,
+    prop3                                            AS prop3,
+    CAST(point                     AS BIGINT)        AS point,
+    order_type                                       AS order_type,
+    CAST(trade_amount              AS DECIMAL(20,4)) AS trade_amount,
+    refund_type                                      AS refund_type,
+    refund_reason                                    AS refund_reason,
+    evaluation                                       AS evaluation,
+    CAST(user_refund_time          AS TIMESTAMP)     AS user_refund_time,
+    CAST(refund_status             AS BIGINT)        AS refund_status,
+    merchant_refund_reason                           AS merchant_refund_reason,
+    CAST(point_deduct              AS DECIMAL(20,4)) AS point_deduct,
+    CAST(shipping_cost             AS DECIMAL(20,4)) AS shipping_cost,
+    merchant_remark                                  AS merchant_remark,
+    CAST(pay_record                AS BIGINT)        AS pay_record,
+    order_sub_type                                   AS order_sub_type,
+    give_user_code                                   AS give_user_code,
+    CAST(give_order_id             AS BIGINT)        AS give_order_id,
+    CAST(read_flag                 AS BIGINT)        AS read_flag,
+    CAST(give_num                  AS BIGINT)        AS give_num,
+    CAST(invoice_id                AS BIGINT)        AS invoice_id,
+    combination_no                                   AS combination_no,
+    CAST(open_self                 AS BIGINT)        AS open_self,
+    refund_desc                                      AS refund_desc,
+    CAST(goods_allocate            AS BIGINT)        AS goods_allocate,
+    CAST(close_payment_status      AS BIGINT)        AS close_payment_status,
+    CAST(close_payment_time        AS TIMESTAMP)     AS close_payment_time,
+    CAST(finished_time             AS TIMESTAMP)     AS finished_time,
+    CAST(expire_time               AS TIMESTAMP)     AS expire_time,
+    CAST(settlement_amount         AS DECIMAL(20,4)) AS settlement_amount,
+    CAST(platform_coupon           AS BIGINT)        AS platform_coupon,
+    CAST(platform_discount         AS DECIMAL(20,4)) AS platform_discount,
+    CAST(discount_amount           AS DECIMAL(20,4)) AS discount_amount,
+    CAST(member_discount           AS DECIMAL(20,4)) AS member_discount,
+    CAST(shipping_free_id          AS BIGINT)        AS shipping_free_id,
+    CAST(shipping_free_amount      AS DECIMAL(20,4)) AS shipping_free_amount,
+    CAST(discount_point            AS BIGINT)        AS discount_point,
+    CAST(un_shipped_num            AS BIGINT)        AS un_shipped_num,
+    CAST(pre_un_shipped_num        AS BIGINT)        AS pre_un_shipped_num,
+    CAST(wait_shipped_num          AS BIGINT)        AS wait_shipped_num,
+    CAST(pre_wait_shipped_num      AS BIGINT)        AS pre_wait_shipped_num,
+    CAST(refuse_time               AS TIMESTAMP)     AS refuse_time,
+    CAST(refuse_notice             AS BIGINT)        AS refuse_notice,
+    CAST(pickup_time               AS TIMESTAMP)     AS pickup_time,
+    waring_type                                      AS waring_type,
+    CAST(waring_status             AS BIGINT)        AS waring_status,
+    point_type                                       AS point_type,
+    CAST(delivery_end_time         AS TIMESTAMP)     AS delivery_end_time,
+    CAST(serve_status              AS BIGINT)        AS serve_status,
+    CAST(self_pickup_time          AS TIMESTAMP)     AS self_pickup_time,
+    CAST(act_discount              AS DECIMAL(20,4)) AS act_discount,
+    CASE WHEN del_flg = '1' THEN TRUE ELSE FALSE END AS is_deleted,
+    ods_dt                                           AS dt
+FROM (
+    SELECT *,
+        DATE_FORMAT(update_time, 'yyyyMMdd') AS ods_dt,
+        ROW_NUMBER() OVER (
+            PARTITION BY id, DATE_FORMAT(update_time, 'yyyyMMdd')
+            ORDER BY update_time DESC
+        ) AS rn
+    FROM (
+        SELECT
+            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
+        FROM raw.raw_trd_card_group_order_info_his_o
+        UNION ALL
+        SELECT
+            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
+        FROM raw.raw_trd_card_group_order_info_inc_d
+    ) u
+) t
+WHERE t.rn = 1;