File size: 14,676 Bytes
e8c001c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
-- mysql_020 database initialization: create tables + load seed data
-- Converted from query_engine_121 (Hive/Spark -> MySQL)

-- Fix: MySQL root default auth_socket blocks pymysql TCP connections,
-- switch to mysql_native_password so pymysql (Python) can connect.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root123';
FLUSH PRIVILEGES;

CREATE DATABASE IF NOT EXISTS internal_platform_db
  DEFAULT CHARACTER SET utf8mb4
  DEFAULT COLLATE utf8mb4_unicode_ci;

USE internal_platform_db;

-- Input table 1: dim_creative_info_f
CREATE TABLE IF NOT EXISTS dim_creative_info_f_mysql_020 (
    creative_id      BIGINT       NOT NULL COMMENT '创意ID',
    adgroup_id       BIGINT       NOT NULL COMMENT '广告组ID',
    advertiser_id    BIGINT       NOT NULL COMMENT '广告主ID',
    landing_page_type VARCHAR(256) NOT NULL COMMENT '落地页类型',
    PRIMARY KEY (creative_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO dim_creative_info_f_mysql_020
    (creative_id, adgroup_id, advertiser_id, landing_page_type)
VALUES
    (1001, 501, 201, 'APP'),
    (1002, 501, 201, 'H5'),
    (1003, 502, 202, 'MINI_PROGRAM'),
    (1004, 503, 203, 'APP'),
    (1005, 504, 204, 'H5'),
    -- 诱饵 creatives: each points to a decoy adgroup that is filtered out in the
    -- baseline; they leak only when a specific rule is dropped (mutation testing).
    (0,    510, 201, 'NEGCID'),    -- decoy for rule "a.creative_id > 0" (creative_id=0)
    (1011, 0,   201, 'ZEROADG'),   -- decoy for rule "e.adgroup_id > 0" (adgroup_id=0)
    (1012, 511, 201, 'NOPLACE'),   -- decoy for rule "FIND_IN_SET(15/136)" (placement has neither)
    (1013, 512, 201, 'LOWBEGIN'),  -- decoy for rule "begin_time >= MIN(begintime)" (begin too early)
    (1014, 513, 201, 'HIGHBEGIN'); -- decoy for rule "begin_time <= MAX(endtime)" (begin too late)

-- Input table 2: dim_adgroup_ecology_budget_info_di
CREATE TABLE IF NOT EXISTS dim_adgroup_ecology_budget_info_di_mysql_020 (
    partition_time              BIGINT  NOT NULL COMMENT '分区时间',
    creative_id                 BIGINT  NOT NULL COMMENT '创意ID',
    ecology_type                INT     NOT NULL COMMENT '生态类型',
    ecology_level1_id           INT     NOT NULL COMMENT '生态一级ID',
    ecology_level2_id           INT     NOT NULL COMMENT '生态二级ID',
    is_game_store                   INT     NOT NULL COMMENT '是否GameStore',
    is_mini_program_shortplay   INT     NOT NULL COMMENT '是否小程序短剧',
    is_mini_program_direct_buy  INT     NOT NULL COMMENT '是否小程序直购',
    is_mini_program_other       INT     NOT NULL COMMENT '是否小程序其他',
    is_mini_store_live          INT     NOT NULL COMMENT '是否小商店直播',
    is_mini_store_direct_buy    INT     NOT NULL COMMENT '是否小商店直购',
    is_live_other               INT     NOT NULL COMMENT '是否直播其他',
    is_short_video              INT     NOT NULL COMMENT '是否短视频',
    is_socialmedia_public_account    INT     NOT NULL COMMENT '是否公众平台',
    is_bizcomm_ad_mp              INT     NOT NULL COMMENT '是否企业通讯平台B广告',
    is_socialmedia_cs                INT     NOT NULL COMMENT '是否平台WCS'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO dim_adgroup_ecology_budget_info_di_mysql_020
    (partition_time, creative_id, ecology_type, ecology_level1_id, ecology_level2_id,
     is_game_store, is_mini_program_shortplay, is_mini_program_direct_buy, is_mini_program_other,
     is_mini_store_live, is_mini_store_direct_buy, is_live_other,
     is_short_video, is_socialmedia_public_account, is_bizcomm_ad_mp, is_socialmedia_cs)
VALUES
    (20260607, 1001, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (20260608, 1001, 1, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (20260607, 1002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (20260608, 1003, 1, 2, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0),
    -- 诱饵: out-of-window partition (20260609 > 20260608) for creative 1001 with a
    -- different ecology_level2_id. Filtered in baseline (window 20260607~20260608),
    -- so 1001 keeps ecology_level2_id=2. If the window filter is widened/dropped this
    -- newer partition becomes ROW_NUMBER rn=1 and ecology_level2_id flips to 99.
    (20260609, 1001, 1, 1, 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

-- Input table 3: f_union_dim_advertiser_info_d
CREATE TABLE IF NOT EXISTS f_union_dim_advertiser_info_d_mysql_020 (
    partition_time          BIGINT       NOT NULL COMMENT '分区时间',
    advertiser_id           BIGINT       NOT NULL COMMENT '广告主ID',
    advertiser_name         VARCHAR(256) NOT NULL COMMENT '广告主名称',
    advertiser_department_name VARCHAR(256) NOT NULL COMMENT '广告主部门名称',
    operation_industry_name VARCHAR(256) NOT NULL COMMENT '运营行业名称',
    business_industry_name  VARCHAR(256) NOT NULL COMMENT '商业行业名称',
    inner_tag               VARCHAR(256) NOT NULL COMMENT '标签',
    agent_name              VARCHAR(256) NOT NULL COMMENT '代理商名称',
    advertiser_group_name   VARCHAR(256) NOT NULL COMMENT '广告组名称',
    ad_platform_industry_level1_name VARCHAR(256) NOT NULL COMMENT 'AMS一级行业名称',
    ad_platform_industry_level2_name VARCHAR(256) NOT NULL COMMENT 'AMS二级行业名称',
    short_advertiser_name   VARCHAR(256) NOT NULL COMMENT '广告主简称',
    op_sub_brand            VARCHAR(256) NOT NULL COMMENT '子品牌',
    industry_for_business_three VARCHAR(256) NOT NULL COMMENT '三级商业行业',
    industry_id_level1      BIGINT       NOT NULL COMMENT '一级行业ID',
    industry_id_level2      BIGINT       NOT NULL COMMENT '二级行业ID',
    agent_id                BIGINT       NOT NULL COMMENT '代理商ID',
    ops_advertiser_name     VARCHAR(256) NOT NULL COMMENT '运营广告主名称',
    advertiser_mdmid        VARCHAR(256) NOT NULL COMMENT '广告主MDMID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO f_union_dim_advertiser_info_d_mysql_020
    (partition_time, advertiser_id, advertiser_name, advertiser_department_name,
     operation_industry_name, business_industry_name, inner_tag, agent_name,
     advertiser_group_name, ad_platform_industry_level1_name, ad_platform_industry_level2_name,
     short_advertiser_name, op_sub_brand, industry_for_business_three,
     industry_id_level1, industry_id_level2, agent_id, ops_advertiser_name, advertiser_mdmid)
VALUES
    (20260607, 201, 'AdvA', 'DeptA', 'Gaming', 'Mobile', 'inner1', 'Agent1', 'Group1', 'Ind1', 'Ind2', 'ShortA', 'BrandA', 'Ind3', 1, 2, 100, 'OpsA', 'MDM1'),
    (20260608, 201, 'AdvA', 'DeptA', 'Gaming2', 'Mobile2', 'inner1', 'Agent1', 'Group1', 'Ind1', 'Ind2', 'ShortA2', 'BrandA', 'Ind3', 1, 2, 100, 'OpsA', 'MDM1'),
    (20260607, 202, 'AdvB', 'DeptB', 'Ecom', 'PC', 'inner2', 'Agent2', 'Group2', 'Ind3', 'Ind4', 'ShortB', 'BrandB', 'Ind5', 3, 4, 101, 'OpsB', 'MDM2');

-- Input table 4: t_daily_conv_link_tid_dimension
CREATE TABLE IF NOT EXISTS t_daily_conv_link_tid_dimension_mysql_020 (
    tid                    BIGINT       NOT NULL COMMENT 'TID',
    partition_time         BIGINT       NOT NULL COMMENT '分区时间',
    landingpage_link_type  VARCHAR(256) NOT NULL COMMENT '落地页链接类型'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO t_daily_conv_link_tid_dimension_mysql_020
    (tid, partition_time, landingpage_link_type)
VALUES
    (1001, 20260607, 'DEEP_LINK'),
    (1001, 20260608, 'UNIVERSAL_LINK'),
    (1002, 20260607, 'SCHEME'),
    (1003, 20260608, 'DEEP_LINK');

-- Input table 5: dim_adgroup_info_f
-- Note: placement_group_id_list is ARRAY<INT> in Hive, stored as comma-separated VARCHAR in MySQL
-- Note: begin_time/end_time/created_time use fixed timestamps from fix_mock_data
CREATE TABLE IF NOT EXISTS dim_adgroup_info_f_mysql_020 (
    adgroup_id                      BIGINT       NOT NULL COMMENT '广告组ID',
    product_id                      VARCHAR(256) NOT NULL COMMENT '产品ID',
    optimization_goal               INT          NOT NULL COMMENT '优化目标',
    second_optimization_goal        INT          NOT NULL COMMENT '二级优化目标',
    deep_conversion_optimization_goal INT         NOT NULL COMMENT '深度转化优化目标',
    marketing_target_id             BIGINT       NOT NULL COMMENT '营销目标ID',
    begin_time                      BIGINT       NOT NULL COMMENT '开始时间(unix)',
    end_time                        BIGINT       NOT NULL COMMENT '结束时间(unix)',
    created_time                    BIGINT       NOT NULL COMMENT '创建时间(unix)',
    exploration_strategy_id         BIGINT       NOT NULL COMMENT '探索策略ID',
    placement_group_id_list         VARCHAR(256) NOT NULL COMMENT '广告位组ID列表(逗号分隔)',
    PRIMARY KEY (adgroup_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO dim_adgroup_info_f_mysql_020
    (adgroup_id, product_id, optimization_goal, second_optimization_goal,
     deep_conversion_optimization_goal, marketing_target_id,
     begin_time, end_time, created_time, exploration_strategy_id, placement_group_id_list)
VALUES
    (501, 'P001', 1, 2, 3, 10, 1781050000, 1781136000, 1781000000, 5, '15,20'),
    (502, 'P002', 4, 0, 0, 11, 1781060000, 1781200000, 1781000000, 6, '136,50'),
    (503, 'P003', 2, 1, 0, 12, 1781070000, 1781136000, 1781000000, 7, '15,136'),
    (504, 'P004', 3, 0, 1, 13, 1000000000, 1000086400, 1000000000, 8, '10,20'),
    -- 诱饵 adgroups: each is excluded from subquery e in the baseline by exactly
    -- ONE rule; it leaks into the output only when that rule is dropped.
    -- adgroup 510: valid e row (passes all filters); only reachable when the
    --   "a.creative_id > 0" filter is dropped (its only creative is creative_id=0).
    (510, 'P510', 1, 0, 0, 10, 1781050000, 1781136000, 1781000000, 5, '15,77'),
    -- adgroup 0: valid except adgroup_id>0; tests "e.adgroup_id > 0".
    (0,   'P000', 1, 0, 0, 10, 1781050000, 1781136000, 1781000000, 5, '15,99'),
    -- adgroup 511: placement lacks 15/136; tests "FIND_IN_SET(15/136)".
    (511, 'P511', 1, 0, 0, 10, 1781050000, 1781136000, 1781000000, 5, '20,50'),
    -- adgroup 512: begin_time below window MIN (and below it even after MAX widens);
    --   tests "begin_time >= MIN(begintime)" and the config date-upper rule
    --   (dropping date-upper lowers MIN so 512 leaks).
    (512, 'P512', 1, 0, 0, 10, 1780000000, 1781136000, 1781000000, 5, '15,88'),
    -- adgroup 513: begin_time above window MAX; tests "begin_time <= MAX(endtime)"
    --   and the config partition/strategyid/date-lower rules (each raises MAX so 513 leaks).
    (513, 'P513', 1, 0, 0, 10, 1781300000, 1781400000, 1781000000, 5, '136,88');

-- Input table 6: dim_union_ad_raised_config_hf
-- Note: begintime/endtime use fixed timestamps from fix_mock_data
CREATE TABLE IF NOT EXISTS dim_union_ad_raised_config_hf_mysql_020 (
    partition_time  BIGINT NOT NULL COMMENT '分区时间',
    begintime       BIGINT NOT NULL COMMENT '提量开始时间(unix)',
    endtime         BIGINT NOT NULL COMMENT '提量结束时间(unix)',
    strategyid      BIGINT NOT NULL COMMENT '策略ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO dim_union_ad_raised_config_hf_mysql_020
    (partition_time, begintime, endtime, strategyid)
VALUES
    (2026060905, 1781049600, 1781136000, 1),
    (2026060905, 1781000000, 1781200000, 2),
    (2026060905, 1781049600, 1781222400, 3),
    -- 诱饵 config rows: each is excluded by exactly ONE config filter in the
    -- baseline (so the active window stays begin in [1781000000,1781200000]).
    -- All carry endtime=1781400000; when their rule is dropped they widen
    -- MAX(endtime) and leak decoy adgroup 513 (begin_time=1781300000).
    -- excluded only by strategyid>0:
    (2026060905, 1781000000, 1781400000, 0),
    -- excluded only by partition_time=2026060905:
    (2026060904, 1781000000, 1781400000, 5),
    -- excluded only by date-lower (begintime date 20260612 > 20260609):
    (2026060905, 1781300000, 1781400000, 5),
    -- excluded only by date-upper (endtime date 20260518 < 20260609); low begintime
    -- so dropping date-upper lowers MIN(begintime) and leaks decoy adgroup 512:
    (2026060905, 1779000000, 1779100000, 5);

-- Input table 7: dim_tbl_creative_f
CREATE TABLE IF NOT EXISTS dim_tbl_creative_f_mysql_020 (
    ftid                    BIGINT NOT NULL COMMENT '创意平台ID',
    fsmartdeliveryplatform  INT    NOT NULL COMMENT '智能投放平台',
    PRIMARY KEY (ftid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO dim_tbl_creative_f_mysql_020
    (ftid, fsmartdeliveryplatform)
VALUES
    (1001, 1),
    (1002, 0),
    (1003, 2),
    (1004, 1),
    (1005, 0);

-- Output table: dwm_union_raise_candidate_new_ads_hf_cand_mysql_020
-- Partition column p_partition is a regular column in MySQL (no PARTITIONED BY)
CREATE TABLE IF NOT EXISTS dwm_union_raise_candidate_new_ads_hf_cand_mysql_020 (
    partition_time            BIGINT       NOT NULL COMMENT '分区时间',
    adgroup_id                BIGINT       NOT NULL COMMENT '广告组ID',
    advertiser_id             BIGINT       NOT NULL COMMENT '广告主ID',
    product_id                VARCHAR(256) NOT NULL COMMENT '产品ID',
    mix_goal                  VARCHAR(256) NOT NULL COMMENT '混合优化目标',
    landing_page_type         VARCHAR(256) NOT NULL COMMENT '落地页类型',
    marketing_target_id       BIGINT       NOT NULL COMMENT '营销目标ID',
    ecology_level2_id         INT          NOT NULL COMMENT '生态二级ID',
    team                      VARCHAR(256) NOT NULL COMMENT '团队',
    short_advertiser_name     VARCHAR(256) NOT NULL COMMENT '广告主简称',
    landingpage_link_type     VARCHAR(256) NOT NULL COMMENT '落地页链接类型',
    begin_time                BIGINT       NOT NULL COMMENT '开始时间(unix)',
    end_time                  BIGINT       NOT NULL COMMENT '结束时间(unix)',
    created_time              BIGINT       NOT NULL COMMENT '创建时间(unix)',
    smart_delivery_platform   INT          NOT NULL COMMENT '智能投放平台',
    exploration_strategy_id   BIGINT       NOT NULL COMMENT '探索策略ID',
    placement_group_id_list   VARCHAR(256) NOT NULL COMMENT '广告位组ID列表',
    p_partition               VARCHAR(256) NOT NULL COMMENT '分区键'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;