Datasets:
File size: 3,634 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 | ---
id: offline-compute_MySQL_mysql_013
name: Notebook Cross-Day Instance Pod Runtime Detail
category: offline-compute/MySQL
timeout_seconds: 1800
modality: pure-text
engine: mysql
---
## Prompt
I need you to generate a MySQL script that splits Notebook runner cross-day instances by day, joins with service instance, Pod, GPU aggregation, and engine information, to produce cross-day instance Pod runtime detail records.
**Business Background and Objective**: Instances in the Notebook runner may run across multiple days. The detail records need to be split by day and joined with service instance mapping, Pod names, GPU aggregation metrics, and engine configuration information, ultimately producing detail records at the instance × Pod × day granularity.
**Input Tables (full name + brief description)**:
- `internal_platform_db.notebook_span_info_mysql_013` (Notebook span information table)
- `internal_platform_db.dwd_gputj_service_instance_map_mysql_013` (service instance mapping table)
- `internal_platform_db.dwd_ml_platform_instance_podname_mysql_013` (instance Pod name table)
- `internal_platform_db.gputj_gpu_info_parsed_agg_1min_mysql_013` (GPU aggregation metrics table)
- `internal_platform_db.notebook_engine_info_mysql_013` (engine configuration information table)
(Please connect to the database and query to confirm the table structures and field semantics.)
**Processing Rules**:
1. Identify cross-day instances from `notebook_span_info` (`compute_type='ray'` AND `service_name='notebook-runner'` AND `span_name='runner.execute'`), split them by day, and generate detail records for each instance per day;
2. Obtain `serving_id` via `notebook_engine_info`, then join with `dwd_gputj_service_instance_map` on `service_id` (i.e., `serving_id`) to obtain `instance_uuid`, and subsequently retrieve service instance mapping information;
3. Join with `dwd_ml_platform_instance_podname` on `instance_uuid` to obtain Pod name information;
4. Join with `gputj_gpu_info_parsed_agg_1min` on Pod name and time granularity to obtain GPU aggregation metrics;
5. Join with `notebook_engine_info` on `trace_id` to obtain engine configuration information (`serving_id`, `is_permanent`, `apply_for_gpu_count`, etc.).
**Output Requirements**:
- Output granularity: instance × Pod × day;
- Output fields: `trace_id`, `datawd_project_id`, `datawd_task_id`, `datawd_task_instance_id`, `compute_type`, `status_code`, `instance_run_time`, `code_run_time`, `resource_wait_time`, `code_start_time`, `code_end_time`, `instance_start_time`, `instance_end_time`, `serving_id`, `is_permanent`, `apply_for_gpu_count`, `pod_name`, `pkg_agg_time`, `gpu_util`, `gpu_count`, `p_date`, `dt`
- Sort by instance ID and date
**Write Requirements**:
- Target table: `internal_platform_db.dwd_notebook_instance_pod_cross_day_detail_d_cand_mysql_013`
- Write mode: `INSERT INTO ... SELECT`
- If the target table does not exist, first create it using standard MySQL InnoDB format, then write the data
- Use standard MySQL syntax; do not use Hive/Spark SQL dialects
**Environment and Execution Notes**:
- Your final output must be written to the file `/tmp_workspace/result.py`, not `result.sql`
- The local MySQL is running at localhost:3306, username `root`, password `root123`
- Use Python `pymysql` in `result.py` to execute the SQL (do not use the `mysql` command-line tool)
- The script must include complete table creation (if the target table does not exist) and data writing logic
- After writing `result.py`, you must execute `python3 /tmp_workspace/result.py` yourself to verify that it runs successfully and produces correct data
|