File size: 26,115 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
-- mysql_003 database initialization: create tables + load seed data
-- Executed via: mysql -u root < init_db.sql
--
-- NOTE: This includes ALL data from build_inputs, AC_rerun, and landing phases
-- to produce the expected 58-row output matching expected.csv.

-- 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: aide_offline_inference_info_fixed
CREATE TABLE IF NOT EXISTS aide_offline_inference_info_fixed_mysql_003 (
    id INT COMMENT 'id',
    wsid INT COMMENT 'wsid',
    name VARCHAR(256) COMMENT 'name',
    `desc` VARCHAR(256) COMMENT 'desc',
    inference_id INT,
    service_id INT,
    model_ids VARCHAR(256),
    input_config VARCHAR(256),
    output_config VARCHAR(256),
    visible INT,
    create_time VARCHAR(256),
    update_time VARCHAR(256),
    status VARCHAR(256),
    pipeline VARCHAR(256),
    modifier_id INT,
    source INT,
    users VARCHAR(256),
    celery_id VARCHAR(256),
    base VARCHAR(256),
    model_change INT,
    inference_config VARCHAR(256),
    location VARCHAR(256),
    activity_id INT,
    api_token VARCHAR(256),
    activity_body VARCHAR(256),
    file_id INT,
    max_wait_time_in_day INT,
    is_timeout INT,
    model_type VARCHAR(256),
    job_type VARCHAR(256),
    submit_type VARCHAR(256),
    item_retry_inference_count INT,
    pass_n_config VARCHAR(256),
    enable_debug INT,
    debug_ttl INT,
    retry_count INT,
    debug_expire_time VARCHAR(256),
    enable_proxy INT,
    enable_post_process INT,
    enable_only_model_deploy INT,
    enable_global_cache INT,
    service_name VARCHAR(256),
    custom_eval_task_config VARCHAR(256),
    is_custom_eval_task INT,
    custom_eval_service_id INT,
    spark_config VARCHAR(256),
    dt BIGINT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs: original seed data
INSERT INTO aide_offline_inference_info_fixed_mysql_003 VALUES
(1001, 100, 'task_alpha', 'desc1', 1, 1, '{"mould_id": 501, "mould_name": "model_A"}', '{}', '{}', 1, '2026-05-07 06:30:00', '2026-05-07 06:55:00', 'RUNNING', '{}', 1, 1, 'user1', 'cel1', 'JOB', 0, '{"config":"val1"}', 'sh', 0, '', '', 201, 3, 0, 'STATIC_MODEL', 'NORMAL', 'API', 1, '', 0, 0, 3, '', 0, 0, 0, 0, '', '', 0, 0, '', 2026050700),
(1002, 100, 'task_beta', 'desc2', 2, 2, '{"mould_id": 502, "mould_name": "model_B"}', '{}', '{}', 1, '2026-05-07 05:00:00', '2026-05-07 06:50:00', 'FINISH', '{}', 1, 1, 'user2', 'cel2', 'JOB', 0, '{"config":"val2"}', 'sh', 0, '', '', 202, 3, 0, 'STATIC_MODEL', 'NORMAL', 'WEB', 1, '', 0, 0, 3, '', 0, 0, 0, 0, '', '', 0, 0, '', 2026050700),
(1003, 100, 'task_gamma', 'desc3', 3, 3, '{"mould_id": 503, "mould_name": "model_C"}', '{}', '{}', 1, '2026-05-07 06:10:00', '2026-05-07 06:40:00', 'FAILED', '{}', 1, 1, 'user3', 'cel3', 'JOB', 0, '{"config":"val3"}', 'bj', 0, '', '', 203, 3, 0, 'STATIC_MODEL', 'NORMAL', 'API', 1, '', 0, 0, 3, '', 0, 0, 0, 0, '', '', 0, 0, '', 2026050700),
(1004, 100, 'task_delta', 'desc4', 4, 4, '{"mould_id": 504, "mould_name": "model_D"}', '{}', '{}', 1, '2026-04-01 10:00:00', '2026-04-01 11:00:00', 'FINISH', '{}', 1, 1, 'user4', 'cel4', 'JOB', 0, '{}', 'sh', 0, '', '', 204, 3, 0, 'STATIC_MODEL', 'NORMAL', 'API', 1, '', 0, 0, 3, '', 0, 0, 0, 0, '', '', 0, 0, '', 2026050700),
(1005, 100, 'task_epsilon', 'desc5', 5, 5, '{"mould_id": 505, "mould_name": "model_E"}', '{}', '{}', 1, '2026-05-07 06:20:00', '2026-05-07 06:45:00', 'KILL', '{}', 1, 1, 'user5', 'cel5', 'OTHER', 0, '{}', 'sh', 0, '', '', 205, 3, 0, 'STATIC_MODEL', 'NORMAL', 'API', 1, '', 0, 0, 3, '', 0, 0, 0, 0, '', '', 0, 0, '', 2026050700);

-- AC_rerun insert: id=1001 (WEB/submit_type, model_x, create_time=00:10)
INSERT INTO aide_offline_inference_info_fixed_mysql_003 VALUES
(1001, 100, 'task_alpha', 'desc1', 1, 1, '{"mould_id": 501, "mould_name": "model_x"}', '', '', 1, '2026-05-07 00:10:00', '2026-05-07 00:30:00', 'RUNNING', '', 0, 0, '', '', 'JOB', 0, '{"batch":10}', 'shanghai', 0, '', '', 2001, 7, 0, 'STATIC_MODEL', 'BATCH', 'WEB', 3, '', 0, 0, 2, '', 0, 0, 0, 0, 'svc_alpha', '', 0, 0, '', 2026050700),
(1002, 100, 'task_beta', 'desc2', 2, 2, '{"mould_id": 502, "mould_name": "model_y"}', '', '', 1, '2026-05-06 23:50:00', '2026-05-06 23:55:00', 'FINISH', '', 0, 0, '', '', 'JOB', 0, '{"batch":20}', 'beijing', 0, '', '', 2002, 7, 0, 'STATIC_MODEL', 'BATCH', 'API', 3, '', 0, 0, 2, '', 0, 0, 0, 0, 'svc_beta', '', 0, 0, '', 2026050700);

-- landing insert: id=1001 (API/submit_type, model_a), id=1002 (WEB, model_b), id=1003 (SDK, model_c)
INSERT INTO aide_offline_inference_info_fixed_mysql_003 VALUES
(1001, 100, 'task_alpha', 'desc1', 1, 1, '{"mould_id": 501, "mould_name": "model_a"}', '{}', '{}', 1, '2026-05-07 00:10:00', '2026-05-07 00:30:00', 'RUNNING', '{}', 1, 1, 'user1', 'cel1', 'JOB', 0, '{"key":"val"}', 'bj', 0, 'token1', '{}', 201, 3, 0, 'STATIC_MODEL', 'BATCH', 'API', 1, '{}', 0, 3600, 1, NULL, 0, 0, 0, 0, 'svc1', '{}', 0, 0, '{}', 2026050700),
(1002, 100, 'task_beta', 'desc2', 2, 2, '{"mould_id": 502, "mould_name": "model_b"}', '{}', '{}', 1, '2026-05-07 00:15:00', '2026-05-07 00:45:00', 'FINISH', '{}', 1, 1, 'user2', 'cel2', 'JOB', 0, '{"key2":"val2"}', 'sh', 0, 'token2', '{}', 202, 3, 0, 'STATIC_MODEL', 'BATCH', 'WEB', 1, '{}', 0, 3600, 1, NULL, 0, 0, 0, 0, 'svc2', '{}', 0, 0, '{}', 2026050700),
(1003, 100, 'task_gamma', 'desc3', 3, 3, '{"mould_id": 503, "mould_name": "model_c"}', '{}', '{}', 1, '2026-05-07 00:20:00', '2026-05-07 00:50:00', 'FAILED', '{}', 1, 1, 'user3', 'cel3', 'JOB', 0, '{"key3":"val3"}', 'gz', 0, 'token3', '{}', 203, 3, 0, 'STATIC_MODEL', 'BATCH', 'SDK', 1, '{}', 0, 3600, 1, NULL, 0, 0, 0, 0, 'svc3', '{}', 0, 0, '{}', 2026050700);

-- 诱饵 (main-table filter decoys): each passes ALL other WHERE conditions but
-- fails exactly ONE filter, so the correct GT removes it (baseline unchanged at
-- 58 rows). If that single filter is dropped, the decoy leaks into the output.
-- id=1006: base='OTHER' (only the base='JOB' filter removes it)
-- id=1007: model_type='DYNAMIC_MODEL' (only the model_type filter removes it)
INSERT INTO aide_offline_inference_info_fixed_mysql_003 VALUES
(1006, 100, 'task_decoy_base', 'descD', 1, 1, '{"mould_id": 501, "mould_name": "model_a"}', '{}', '{}', 1, '2026-05-07 00:30:00', '2026-05-07 00:31:00', 'RUNNING', '{}', 1, 1, 'user1', 'cel1', 'OTHER', 0, '{"key":"val"}', 'bj', 0, 'token1', '{}', 201, 3, 0, 'STATIC_MODEL', 'NORMAL', 'API', 1, '{}', 0, 3600, 1, NULL, 0, 0, 0, 0, 'svc1', '{}', 0, 0, '{}', 2026050700),
(1007, 100, 'task_decoy_mt', 'descD', 1, 1, '{"mould_id": 501, "mould_name": "model_a"}', '{}', '{}', 1, '2026-05-07 00:30:00', '2026-05-07 00:31:00', 'RUNNING', '{}', 1, 1, 'user1', 'cel1', 'JOB', 0, '{"key":"val"}', 'bj', 0, 'token1', '{}', 201, 3, 0, 'DYNAMIC_MODEL', 'NORMAL', 'API', 1, '{}', 0, 3600, 1, NULL, 0, 0, 0, 0, 'svc1', '{}', 0, 0, '{}', 2026050700);


-- Input Table 2: aide_offline_inference_dataset_info_h
CREATE TABLE IF NOT EXISTS aide_offline_inference_dataset_info_h_mysql_003 (
    id INT,
    file_id INT,
    offline_inference_id INT,
    stage_id INT,
    result_file_name VARCHAR(256),
    result_file_path VARCHAR(256),
    inference_result_data_url VARCHAR(256),
    dataset_act_num BIGINT,
    dataset_fin_num BIGINT,
    create_time VARCHAR(256),
    update_time VARCHAR(256),
    dataset_err_num BIGINT,
    inference_failed_result_data_url VARCHAR(256),
    dataset_exp_num BIGINT,
    remaining_time VARCHAR(256),
    output_file_id INT,
    error_file_id INT,
    inference_unprocessed_data_url VARCHAR(256),
    hifs_result_file_path VARCHAR(256),
    task_waiting_info VARCHAR(256),
    etl_stamp VARCHAR(256)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs
INSERT INTO aide_offline_inference_dataset_info_h_mysql_003 VALUES
(1, 201, 1001, 1, 'res1.csv', '/path/res1', 'http://url1', 1000, 950, '2026-05-07 06:30:00', '2026-05-07 06:55:00', 10, '', 1000, '5m', 1, 1, '', '', '', ''),
(2, 202, 1002, 2, 'res2.csv', '/path/res2', 'http://url2', 500, 500, '2026-05-07 05:00:00', '2026-05-07 06:50:00', 0, '', 500, '0m', 2, 2, '', '', '', ''),
(3, 203, 1003, 3, 'res3.csv', '/path/res3', 'http://url3', 200, 100, '2026-05-07 06:10:00', '2026-05-07 06:40:00', 50, '', 200, '10m', 3, 3, '', '', '', '');

-- AC_rerun insert: dataset for 3001/3002 stage
INSERT INTO aide_offline_inference_dataset_info_h_mysql_003 VALUES
(4, 2001, 1001, 3001, 'result1.csv', '/path/r1', 'http://url1', 1000, 900, '2026-05-07 00:11:00', '2026-05-07 00:20:00', 50, 'http://err1', 1000, '10min', 10, 11, 'http://unp1', '/hifs/r1', '', ''),
(5, 2002, 1002, 3002, 'result2.csv', '/path/r2', 'http://url2', 500, 480, '2026-05-06 23:51:00', '2026-05-06 23:55:00', 20, 'http://err2', 500, '5min', 20, 21, 'http://unp2', '/hifs/r2', '', '');

-- landing insert: dataset for 301/302/303 stages with small numbers
INSERT INTO aide_offline_inference_dataset_info_h_mysql_003 VALUES
(6, 201, 1001, 1, 'result1.csv', '/path/r1', 'http://url1', 100, 80, '2026-05-07 00:12:00', '2026-05-07 00:30:00', 5, 'http://err1', 100, '10min', 301, 401, 'http://unp1', '/hifs/r1', '{}', 'stamp1'),
(7, 202, 1002, 2, 'result2.csv', '/path/r2', 'http://url2', 200, 200, '2026-05-07 00:16:00', '2026-05-07 00:45:00', 0, 'http://err2', 200, '0min', 302, 402, 'http://unp2', '/hifs/r2', '{}', 'stamp2'),
(8, 203, 1003, 3, 'result3.csv', '/path/r3', 'http://url3', 150, 50, '2026-05-07 00:22:00', '2026-05-07 00:50:00', 30, 'http://err3', 150, '20min', 303, 403, 'http://unp3', '/hifs/r3', '{}', 'stamp3');


-- Input Table 3: aide_offline_inference_stage_info_h
CREATE TABLE IF NOT EXISTS aide_offline_inference_stage_info_h_mysql_003 (
    id INT,
    offline_inference_id INT,
    mould_id INT,
    deployment_id INT,
    scaleup_id INT,
    mq_info_id INT,
    dataset_exp_num INT,
    dataset_act_num INT,
    dataset_fin_num INT,
    status VARCHAR(256),
    create_time VARCHAR(256),
    update_time VARCHAR(256),
    modifier_id INT,
    error_msg VARCHAR(256),
    etl_stamp VARCHAR(256)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs
INSERT INTO aide_offline_inference_stage_info_h_mysql_003 VALUES
(301, 1001, 501, 1, 1, 1, 1000, 1000, 950, 'RUNNING', '2026-05-07 06:30:00', '2026-05-07 06:55:00', 1, '', ''),
(302, 1002, 502, 2, 2, 2, 500, 500, 500, 'FINISH', '2026-05-07 05:00:00', '2026-05-07 06:50:00', 1, '', ''),
(303, 1003, 503, 3, 3, 3, 200, 200, 100, 'FAILED', '2026-05-07 06:10:00', '2026-05-07 06:40:00', 1, 'error', '');

-- AC_rerun insert: stage 3001/3002
INSERT INTO aide_offline_inference_stage_info_h_mysql_003 VALUES
(3001, 1001, 501, 1, 1, 1, 1000, 1000, 900, 'RUNNING', '2026-05-07 00:11:00', '2026-05-07 00:20:00', 0, '', ''),
(3002, 1002, 502, 2, 2, 2, 500, 500, 480, 'FINISH', '2026-05-06 23:51:00', '2026-05-06 23:55:00', 0, '', '');

-- landing insert: stage 5001/5002/5003
INSERT INTO aide_offline_inference_stage_info_h_mysql_003 VALUES
(5001, 1001, 501, 1, 1, 1, 100, 100, 80, 'RUNNING', '2026-05-07 00:11:00', '2026-05-07 00:30:00', 1, NULL, 'stamp1'),
(5002, 1002, 502, 2, 2, 2, 200, 200, 200, 'FINISH', '2026-05-07 00:16:00', '2026-05-07 00:45:00', 1, NULL, 'stamp2'),
(5003, 1003, 503, 3, 3, 3, 150, 150, 50, 'FAILED', '2026-05-07 00:21:00', '2026-05-07 00:50:00', 1, 'timeout', 'stamp3');


-- Input Table 4: aide_offline_inference_pipeline_time
CREATE TABLE IF NOT EXISTS aide_offline_inference_pipeline_time_mysql_003 (
    id BIGINT,
    task_id INT,
    stage_id INT,
    step INT,
    step_desc VARCHAR(256),
    start_time VARCHAR(256),
    end_time VARCHAR(256),
    status VARCHAR(256),
    time_cost_in_second BIGINT,
    etl_stamp VARCHAR(256)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs
INSERT INTO aide_offline_inference_pipeline_time_mysql_003 VALUES
(1, 1001, 301, 1, '任务下发', '2026-05-07 06:30:00', '2026-05-07 06:32:00', 'DONE', 120, ''),
(2, 1001, 301, 2, '离线推理', '2026-05-07 06:32:00', '2026-05-07 06:50:00', 'DONE', 1080, ''),
(3, 1002, 302, 1, '任务下发', '2026-05-07 05:00:00', '2026-05-07 05:01:00', 'DONE', 60, ''),
(4, 1002, 302, 2, '离线推理', '2026-05-07 05:01:00', '2026-05-07 06:30:00', 'DONE', 5340, ''),
(5, 1003, 303, 1, '任务下发', '2026-05-07 06:10:00', '2026-05-07 06:11:00', 'DONE', 60, ''),
(6, 1003, 303, 2, '离线推理', '2026-05-07 06:11:00', NULL, 'RUNNING', 0, '');

-- 诱饵 (pipeline end_time IS NOT NULL filter): an unfinished step (end_time NULL)
-- with a NON-ZERO time_cost for an existing task_id. Correct GT excludes it
-- (SUM for task 1001 stays 1200); if the end_time filter is dropped it leaks into
-- the SUM (1200 -> 1700), so the rule becomes detectable. Baseline unchanged.
INSERT INTO aide_offline_inference_pipeline_time_mysql_003 VALUES
(7, 1001, 301, 3, '离线推理', '2026-05-07 06:50:00', NULL, 'RUNNING', 500, '');

-- NOTE: AC_rerun pipeline_time INSERTs are skipped because they did not execute
-- successfully in the original Hive (wrong table names / ID conflicts).
-- The expected.csv shows only build_inputs pipeline data in the aggregation results.


-- Input Table 5: aide_offline_inference_file_info_h
CREATE TABLE IF NOT EXISTS aide_offline_inference_file_info_h_mysql_003 (
    create_time VARCHAR(256),
    file_download_url VARCHAR(256),
    file_name VARCHAR(256),
    file_path VARCHAR(256),
    file_type VARCHAR(256),
    id INT,
    operator VARCHAR(256),
    scan_result VARCHAR(256),
    scan_status VARCHAR(256),
    storage_conf VARCHAR(256),
    storage_type VARCHAR(256),
    update_time VARCHAR(256),
    dt VARCHAR(256),
    etl_stamp VARCHAR(256)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs
INSERT INTO aide_offline_inference_file_info_h_mysql_003 VALUES
('2026-05-07 06:25:00', 'http://dl1', 'file1.csv', '/path/f1', 'CSV', 201, 'submitter_A', '', '', '', 'COS', '2026-05-07 06:30:00', '2026050700', ''),
('2026-05-07 04:55:00', 'http://dl2', 'file2.csv', '/path/f2', 'CSV', 202, 'submitter_B', '', '', '', 'COS', '2026-05-07 05:00:00', '2026050700', ''),
('2026-05-07 06:05:00', 'http://dl3', 'file3.csv', '/path/f3', 'CSV', 203, 'submitter_C', '', '', '', 'COS', '2026-05-07 06:10:00', '2026050700', '');

-- AC_rerun insert: file 2001/2002 (user_zhang/user_li)
INSERT INTO aide_offline_inference_file_info_h_mysql_003 VALUES
('2026-05-06 23:00:00', 'http://dl1', 'input1.csv', '/path/input1', 'csv', 2001, 'user_zhang', '', 'PASS', '', 'COS', '2026-05-07 00:05:00', '2026050700', ''),
('2026-05-06 22:00:00', 'http://dl2', 'input2.csv', '/path/input2', 'csv', 2002, 'user_li', '', 'PASS', '', 'COS', '2026-05-06 22:30:00', '2026050700', '');

-- landing insert: file 201/202/203 (submitter_a/b/c)
INSERT INTO aide_offline_inference_file_info_h_mysql_003 VALUES
('2026-05-07 00:09:00', 'http://dl1', 'input1.jsonl', '/path/f1', 'jsonl', 201, 'submitter_a', 'OK', 'PASS', '{}', 'cos', '2026-05-07 00:09:00', '2026050700', 'stamp1'),
('2026-05-07 00:14:00', 'http://dl2', 'input2.jsonl', '/path/f2', 'jsonl', 202, 'submitter_b', 'OK', 'PASS', '{}', 'cos', '2026-05-07 00:14:00', '2026050700', 'stamp2'),
('2026-05-07 00:19:00', 'http://dl3', 'input3.jsonl', '/path/f3', 'jsonl', 203, 'submitter_c', 'OK', 'PASS', '{}', 'cos', '2026-05-07 00:19:00', '2026050700', 'stamp3');

-- 诱饵 (file current-hour dt filter): a row in a DIFFERENT partition (dt='2026050623')
-- for an existing file id=2001 with a LATER update_time than the current-partition
-- row. Correct GT filters by dt='2026050700' and never sees it (baseline unchanged).
-- If the dt filter is dropped, ROW_NUMBER (ORDER BY update_time DESC) would pick this
-- decoy, changing submit_operator/submit_time — so the rule becomes detectable.
INSERT INTO aide_offline_inference_file_info_h_mysql_003 VALUES
('2026-05-06 23:00:00', 'http://dlX', 'inputX.csv', '/path/inputX', 'csv', 2001, 'decoy_operator', '', 'PASS', '', 'COS', '2026-05-07 09:00:00', '2026050623', '');


-- Input Table 6: aide_mould_h
-- NOTE: This table has ~90 columns. Many VARCHAR columns would exceed MySQL's
-- 65535-byte row size limit under utf8mb4. Non-key, non-filter columns are changed to TEXT.
CREATE TABLE IF NOT EXISTS aide_mould_h_mysql_003 (
    id INT,
    create_time VARCHAR(64),
    update_time VARCHAR(64),
    name VARCHAR(128),
    `desc` TEXT,
    path TEXT,
    checkpoint TEXT,
    `enum` VARCHAR(64),
    source VARCHAR(64),
    job_id INT,
    modifier_id INT,
    dep TEXT,
    scale TEXT,
    total_parameters TEXT,
    activate_parameters TEXT,
    stage VARCHAR(64),
    style VARCHAR(64),
    wsid INT,
    pub INT,
    category VARCHAR(64),
    queue_name VARCHAR(128),
    art INT,
    spaces TEXT,
    spaces_json TEXT,
    template TEXT,
    ch_location TEXT,
    location_infos TEXT,
    flows TEXT,
    amount TEXT,
    context_len TEXT,
    file TEXT,
    remark1 TEXT,
    remark2 TEXT,
    ver_style VARCHAR(64),
    disable INT,
    old_path TEXT,
    tokenizer TEXT,
    pattern VARCHAR(64),
    rlhf_pattern VARCHAR(64),
    online INT,
    source_path TEXT,
    scene_text_type VARCHAR(64),
    scene_type VARCHAR(64),
    wwfs_path TEXT,
    compression_strategy VARCHAR(64),
    compression_path TEXT,
    vit_input_resolution VARCHAR(64),
    relate_base_mould TEXT,
    relate_base_id INT,
    relate_base_enum VARCHAR(64),
    father_mould TEXT,
    visual_structure TEXT,
    only_save_lora INT,
    cos_bucket TEXT,
    bucket_region VARCHAR(64),
    old_compression_path TEXT,
    disable_execute INT,
    task_instance_name TEXT,
    train_task_name TEXT,
    train_mode VARCHAR(64),
    sft_tokenizer TEXT,
    model_structure VARCHAR(64),
    benchmark_id VARCHAR(64),
    scene_train VARCHAR(64),
    image_model_id VARCHAR(64),
    trigger_prompt TEXT,
    image_tag VARCHAR(64),
    model_type VARCHAR(64),
    from_inference_id VARCHAR(64),
    from_inference_data TEXT,
    hf_model_path TEXT,
    hf_version INT,
    config_content TEXT,
    audio_encoder_path TEXT,
    audio_decode_before_path TEXT,
    audio_decode_after_path TEXT,
    audio_llm_path TEXT,
    extra_scene_text_type VARCHAR(64),
    copy_state VARCHAR(64),
    copy_tips TEXT,
    use_audio_embeddings INT,
    open_source_type VARCHAR(64),
    icon TEXT,
    manufacturer VARCHAR(64),
    disable_deploy INT,
    show_platform VARCHAR(64),
    extra_info TEXT,
    is_delete INT,
    manufacturer_series VARCHAR(64),
    storage_type VARCHAR(64),
    nas_server TEXT,
    thought_type VARCHAR(64),
    model_source VARCHAR(64),
    deleted INT,
    copy_from_location_id INT,
    etl_stamp VARCHAR(64)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs: model_A/B/C with img_tag_A/B/C
INSERT INTO aide_mould_h_mysql_003 VALUES
(501, '2026-01-01 00:00:00', '2026-01-01 00:00:00', 'model_A', '', '', '', '', '', 0, 0, '', '', '', '', '', '', 100, 0, '', '', 0, '', '', '', '', '', '', '', '', '', '', '', '', 0, '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', '', 0, '', '', '', '', '', '', '', '', '', 'img_tag_A', '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', 0, '', '', '', '', '', 0, 0, ''),
(502, '2026-01-01 00:00:00', '2026-01-01 00:00:00', 'model_B', '', '', '', '', '', 0, 0, '', '', '', '', '', '', 100, 0, '', '', 0, '', '', '', '', '', '', '', '', '', '', '', '', 0, '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', '', 0, '', '', '', '', '', '', '', '', '', 'img_tag_B', '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', 0, '', '', '', '', '', 0, 0, ''),
(503, '2026-01-01 00:00:00', '2026-01-01 00:00:00', 'model_C', '', '', '', '', '', 0, 0, '', '', '', '', '', '', 100, 0, '', '', 0, '', '', '', '', '', '', '', '', '', '', '', '', 0, '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', '', 0, '', '', '', '', '', '', '', '', '', 'img_tag_C', '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', 0, '', '', '', '', '', 0, 0, '');

-- AC_rerun insert: model_x with image_tag=v1.0-alpha
INSERT INTO aide_mould_h_mysql_003 VALUES
(501, '2026-01-01 00:00:00', '2026-05-01 00:00:00', 'model_x', '', '', '', '', '', 0, 0, '', '', '', '', '', '', 100, 0, '', '', 0, '', '', '', '', '', '', '', '', '', '', '', '', 0, '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', '', 0, '', '', '', '', '', '', '', '', '', 'v1.0-alpha', '', '', '', '', 0, '', '', '', '', '', '', '', '', 0, '', '', '', 0, '', '', 0, '', '', '', '', '', 0, 0, '');

-- NOTE: landing inserts for aide_mould_h were skipped because the original Hive SQL
-- had column count mismatches that caused those INSERTs to fail silently.

-- Input Table 7: task_instance_wait_time_stats
CREATE TABLE IF NOT EXISTS task_instance_wait_time_stats_mysql_003 (
    dt VARCHAR(256),
    instance_uuid VARCHAR(256),
    task_instance_id VARCHAR(256),
    state_from VARCHAR(256),
    state_to VARCHAR(256),
    time_start DOUBLE,
    time_end DOUBLE,
    first_wait_time DOUBLE,
    wait_time_status VARCHAR(256),
    create_time DOUBLE,
    state VARCHAR(256),
    host_num DOUBLE,
    host_gpu_num DOUBLE,
    task_id VARCHAR(256),
    is_elasticity SMALLINT,
    is_mixing_task SMALLINT,
    is_exist_cluster SMALLINT,
    quota_type VARCHAR(256),
    location VARCHAR(256),
    business_flag VARCHAR(256),
    gpuname VARCHAR(256),
    account VARCHAR(256),
    business_tag VARCHAR(256),
    gpu_num DOUBLE,
    service_id BIGINT,
    service_name VARCHAR(256)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- build_inputs: task_alpha_301_OFFLINE (60,120), task_beta_302_OFFLINE (80)
INSERT INTO task_instance_wait_time_stats_mysql_003 VALUES
('20260507', 'uuid1', 'ti1', 'READY', 'RUNNING', 1746582600.0, 1746582660.0, 60.0, 'OK', 1746582600.0, 'RUNNING', 1.0, 8.0, 't1', 0, 0, 1, 'dedicated', 'sh', 'nextgen_platform', 'A100', 'user1', 'tag1', 8.0, 1, 'task_alpha_301_OFFLINE'),
('20260507', 'uuid2', 'ti2', 'READY', 'RUNNING', 1746582600.0, 1746582720.0, 120.0, 'OK', 1746582600.0, 'RUNNING', 1.0, 8.0, 't2', 0, 0, 1, 'dedicated', 'sh', 'nextgen_platform', 'A100', 'user1', 'tag1', 8.0, 1, 'task_alpha_301_OFFLINE'),
('20260507', 'uuid3', 'ti3', 'READY', 'RUNNING', 1746582600.0, 1746582680.0, 80.0, 'OK', 1746582600.0, 'RUNNING', 1.0, 8.0, 't3', 0, 0, 1, 'dedicated', 'bj', 'nextgen_platform', 'A100', 'user2', 'tag2', 8.0, 2, 'task_beta_302_OFFLINE');

-- AC_rerun insert: task_alpha_3001_OFFLINE (60), task_beta_3002_OFFLINE (120)
INSERT INTO task_instance_wait_time_stats_mysql_003 VALUES
('20260507', 'uuid-001', 'ti-001', 'READY', 'RUNNING', 1746576600.0, 1746576660.0, 60.0, 'OK', 1746576500.0, 'RUNNING', 1.0, 8.0, 'task-001', 0, 0, 1, 'dedicated', 'shanghai', 'teg', 'A100', 'user1', 'ai', 8.0, 100, 'task_alpha_3001_OFFLINE'),
('20260507', 'uuid-002', 'ti-002', 'READY', 'RUNNING', 1746576700.0, 1746576820.0, 120.0, 'OK', 1746576600.0, 'RUNNING', 1.0, 4.0, 'task-002', 0, 0, 1, 'dedicated', 'beijing', 'teg', 'V100', 'user2', 'ai', 4.0, 200, 'task_beta_3002_OFFLINE');

-- landing insert: task_alpha_5001_OFFLINE (300), task_beta_5002_OFFLINE (150), task_gamma_5003_OFFLINE (200)
INSERT INTO task_instance_wait_time_stats_mysql_003 VALUES
('20260507', 'uuid1', 'inst1', 'READY', 'RUNNING', 1746576600.0, 1746576900.0, 300.0, 'OK', 1746576600.0, 'RUNNING', 1.0, 8.0, 'task1', 0, 0, 1, 'dedicated', 'bj', 'inference', 'A100', 'user1', 'tag1', 8.0, 1, 'task_alpha_5001_OFFLINE'),
('20260507', 'uuid2', 'inst2', 'READY', 'RUNNING', 1746576700.0, 1746576850.0, 150.0, 'OK', 1746576700.0, 'RUNNING', 1.0, 4.0, 'task2', 0, 0, 1, 'shared', 'sh', 'inference', 'V100', 'user2', 'tag2', 4.0, 2, 'task_beta_5002_OFFLINE'),
('20260507', 'uuid3', 'inst3', 'READY', 'RUNNING', 1746576800.0, 1746577000.0, 200.0, 'OK', 1746576800.0, 'RUNNING', 1.0, 8.0, 'task3', 0, 0, 1, 'dedicated', 'gz', 'inference', 'A100', 'user3', 'tag3', 8.0, 3, 'task_gamma_5003_OFFLINE');

-- 诱饵 (latest-partition MAX(dt) pick): a STALE partition (dt='20260506') row for
-- an existing service with a wildly different first_wait_time. Correct GT uses
-- MAX(dt)='20260507' and ignores it (baseline unchanged). If the partition pick is
-- broken (e.g. MIN(dt)), this stale value leaks in and the wait stats diverge.
INSERT INTO task_instance_wait_time_stats_mysql_003 VALUES
('20260506', 'uuidS', 'instS', 'READY', 'RUNNING', 1746490000.0, 1746499999.0, 9999.0, 'OK', 1746490000.0, 'RUNNING', 1.0, 8.0, 'taskS', 0, 0, 1, 'dedicated', 'bj', 'inference', 'A100', 'user1', 'tag1', 8.0, 1, 'task_alpha_301_OFFLINE');


-- Output Table: dwd_aide_offline_inference_feature_cand
CREATE TABLE IF NOT EXISTS dwd_aide_offline_inference_feature_cand_mysql_003 (
    dt VARCHAR(256) COMMENT '分区字段',
    create_time VARCHAR(256) COMMENT '创建时间',
    ct INT COMMENT '计数标识',
    id BIGINT COMMENT '离线推理任务ID',
    name VARCHAR(256) COMMENT '任务名称',
    servingName VARCHAR(256) COMMENT '服务名称',
    base VARCHAR(256) COMMENT '基础类型',
    status VARCHAR(256) COMMENT '状态',
    submit_type VARCHAR(256) COMMENT '提交类型',
    mould_id VARCHAR(256) COMMENT '模型ID',
    mould_name VARCHAR(256) COMMENT '模型名称',
    time_cost_in_second BIGINT COMMENT '总耗时(秒)',
    dataset_act_num BIGINT COMMENT '数据集激活数量',
    dataset_fin_num BIGINT COMMENT '数据集完成数量',
    dataset_err_num BIGINT COMMENT '数据集错误数量',
    max_instance_first_wait_time DOUBLE COMMENT '最大首次等待时长(秒)',
    avg_instance_first_wait_time DOUBLE COMMENT '平均首次等待时长(秒)',
    task_dispatch_time BIGINT COMMENT '任务下发耗时(秒)',
    offline_inference_time BIGINT COMMENT '离线推理耗时(秒)',
    inference_config VARCHAR(256) COMMENT '推理配置',
    submit_operator VARCHAR(256) COMMENT '提交人',
    submit_time VARCHAR(256) COMMENT '提交时间',
    image_tag VARCHAR(256) COMMENT '镜像标签'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;