File size: 6,685 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
CREATE DATABASE IF NOT EXISTS internal_platform_db;

-- Input table 1: notebook_span_info
CREATE TABLE IF NOT EXISTS internal_platform_db.notebook_span_info_query_engine_005 (
    databus_imp_date STRING,
    trace_id STRING,
    span_kind STRING,
    error_code STRING,
    service_name STRING,
    message STRING,
    parent_span_id STRING,
    span_name STRING,
    duration BIGINT,
    span_id STRING,
    space_id STRING,
    span_type STRING,
    start_time STRING,
    end_time STRING,
    service_instance STRING,
    status_code INT,
    datawd_project_id STRING,
    datawd_task_id STRING,
    datawd_task_instance_id STRING,
    compute_type STRING
) STORED AS ORC;

INSERT INTO TABLE internal_platform_db.notebook_span_info_query_engine_005 VALUES
('2026050700','trace_001','server','0','notebook-runner','','','runner.execute',60000,'s1','sp1','','1746460800000','1746547200000','inst1',0,'proj_1','task_1','inst_1','ray'),
('2026050700','trace_001','server','0','notebook-runner','','','execute.code',50000,'s2','sp1','','1746464400000','1746540000000','inst1',0,'proj_1','task_1','inst_1','ray'),
('2026050700','trace_001','server','0','notebook-runner','','','set.permanent.compute',5000,'s3','sp1','','1746460800000','1746463200000','inst1',0,'proj_1','task_1','inst_1','ray'),
('2026050500','trace_001','server','0','notebook-runner','','','runner.execute',60000,'s4','sp1','','1746460800000','1746547200000','inst1',0,'proj_1','task_1','inst_1','ray'),
('2026050500','trace_001','server','0','notebook-runner','','','execute.code',50000,'s5','sp1','','1746464400000','1746540000000','inst1',0,'proj_1','task_1','inst_1','ray'),
('2026050700','trace_002','server','0','notebook-runner','','','runner.execute',30000,'s6','sp2','','1746547200000','1746558000000','inst2',1,'proj_2','task_2','inst_2','ray'),
('2026050700','trace_002','server','0','notebook-runner','','','execute.code',25000,'s7','sp2','','1746548000000','1746556000000','inst2',1,'proj_2','task_2','inst_2','ray'),
('2026050700','trace_002','server','0','notebook-runner','','','create.non.permanent.compute',3000,'s8','sp2','','1746547200000','1746548000000','inst2',1,'proj_2','task_2','inst_2','ray');

-- Input table 2: dwd_gputj_service_instance_map
CREATE TABLE IF NOT EXISTS internal_platform_db.dwd_gputj_service_instance_map_query_engine_005 (
    dt STRING,
    service_name STRING,
    instance_uuid STRING,
    service_id BIGINT,
    version_id BIGINT,
    `desc` STRING,
    create_time DOUBLE,
    update_time DOUBLE,
    workload_name STRING
) STORED AS ORC;

INSERT INTO TABLE internal_platform_db.dwd_gputj_service_instance_map_query_engine_005 VALUES
('2026050700','svc_a','uuid_001',1001,1,'desc1',1.0,2.0,'wl1'),
('2026050700','svc_b','uuid_002',1002,1,'desc2',1.0,2.0,'wl2');

-- Input table 3: dwd_ml_platform_instance_podname
CREATE TABLE IF NOT EXISTS internal_platform_db.dwd_ml_platform_instance_podname_query_engine_005 (
    dt STRING,
    instance_uuid STRING,
    pod_name STRING,
    pod_phase STRING,
    pod_create_time BIGINT,
    pod_update_time BIGINT,
    namespace STRING,
    trial_job_name STRING,
    create_time BIGINT,
    modify_time BIGINT,
    fix_modify_time BIGINT
) STORED AS ORC;

INSERT INTO TABLE internal_platform_db.dwd_ml_platform_instance_podname_query_engine_005 VALUES
('2026050700','uuid_001','pod_alpha','Running',1746460000,1746461000,'ns1','job1',1746460000,1746461000,1746461000),
('2026050700','uuid_002','pod_beta','Running',1746460000,1746461000,'ns2','job2',1746460000,1746461000,1746461000);

-- Input table 4: gputj_gpu_info_parsed_agg_1min (MINIMAL - only columns GT uses)
CREATE TABLE IF NOT EXISTS internal_platform_db.gputj_gpu_info_parsed_agg_1min_query_engine_005 (
    dt STRING,
    pod_name STRING,
    pkg_agg_time STRING,
    k8s_container_vgpu_gpu_util_sum DOUBLE,
    k8s_container_vgpu_gpu_util_count BIGINT,
    k8s_container_resource_request_gpu_sum DOUBLE,
    k8s_container_resource_request_gpu_count BIGINT
) STORED AS ORC;

INSERT INTO TABLE internal_platform_db.gputj_gpu_info_parsed_agg_1min_query_engine_005 VALUES
('2026050700','pod_alpha','2026-05-06 02:00:00',160.0,2,4.0,2),
('2026050600','pod_alpha','2026-05-05 20:00:00',140.0,2,2.0,2);

-- Input table 5: notebook_engine_info
CREATE TABLE IF NOT EXISTS internal_platform_db.notebook_engine_info_query_engine_005 (
    databus_imp_date STRING,
    trace_id STRING,
    service_name STRING,
    compute_type STRING,
    datawd_project_id STRING,
    datawd_task_id STRING,
    datawd_task_instance_id STRING,
    is_permanent STRING,
    serving_id STRING,
    user_name STRING,
    is_model_service STRING,
    compute_info STRING,
    num_gpu STRING,
    replicas STRING,
    gpu_type STRING,
    `timestamp` STRING,
    ray_job_id STRING,
    reason STRING,
    log_url STRING,
    dashboard_url STRING
) STORED AS ORC;

INSERT INTO TABLE internal_platform_db.notebook_engine_info_query_engine_005 VALUES
('2026050700','trace_001','notebook-runner','ray','proj_1','task_1','inst_1','true','1001','user1','false','{}','2','1','A100','1746460800','job1','','',''),
('2026050700','trace_002','notebook-runner','ray','proj_2','task_2','inst_2','false','1002','user2','false','{}','1','2','V100','1746547200','job2','','','');

-- Target table
CREATE TABLE IF NOT EXISTS internal_platform_db.dwd_notebook_instance_pod_cross_day_detail_d_query_engine_005 (
    trace_id STRING,
    datawd_project_id STRING,
    datawd_task_id STRING,
    datawd_task_instance_id STRING,
    compute_type STRING,
    status_code INT,
    instance_run_time INT,
    code_run_time INT,
    resource_wait_time INT,
    code_start_time STRING,
    code_end_time STRING,
    instance_start_time STRING,
    instance_end_time STRING,
    serving_id STRING,
    is_permanent STRING,
    apply_for_gpu_count INT,
    pod_name STRING,
    pkg_agg_time STRING,
    gpu_util DOUBLE,
    gpu_count INT,
    p_date STRING
) PARTITIONED BY (dt STRING) STORED AS ORC;

-- Agent 候选目标表
CREATE TABLE IF NOT EXISTS internal_platform_db.dwd_notebook_instance_pod_cross_day_detail_d_cand_query_engine_005 (
    trace_id STRING,
    datawd_project_id STRING,
    datawd_task_id STRING,
    datawd_task_instance_id STRING,
    compute_type STRING,
    status_code INT,
    instance_run_time INT,
    code_run_time INT,
    resource_wait_time INT,
    code_start_time STRING,
    code_end_time STRING,
    instance_start_time STRING,
    instance_end_time STRING,
    serving_id STRING,
    is_permanent STRING,
    apply_for_gpu_count INT,
    pod_name STRING,
    pkg_agg_time STRING,
    gpu_util DOUBLE,
    gpu_count INT,
    p_date STRING
) PARTITIONED BY (dt STRING) STORED AS ORC;