Datasets:
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:
- Identify cross-day instances from
notebook_span_info(compute_type='ray'ANDservice_name='notebook-runner'ANDspan_name='runner.execute'), split them by day, and generate detail records for each instance per day; - Obtain
serving_idvianotebook_engine_info, then join withdwd_gputj_service_instance_maponservice_id(i.e.,serving_id) to obtaininstance_uuid, and subsequently retrieve service instance mapping information; - Join with
dwd_ml_platform_instance_podnameoninstance_uuidto obtain Pod name information; - Join with
gputj_gpu_info_parsed_agg_1minon Pod name and time granularity to obtain GPU aggregation metrics; - Join with
notebook_engine_infoontrace_idto 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, notresult.sql - The local MySQL is running at localhost:3306, username
root, passwordroot123 - Use Python
pymysqlinresult.pyto execute the SQL (do not use themysqlcommand-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 executepython3 /tmp_workspace/result.pyyourself to verify that it runs successfully and produces correct data