Datasets:
id: offline-compute_MySQL_mysql_005
name: GPU Inference Platform P90 Traffic Forecast (Holiday/Workday Differentiation)
category: offline-compute/MySQL
timeout_seconds: 1800
modality: pure-text
engine: mysql
Prompt
I need you to generate a MySQL script that produces 14-day traffic and resource usage forecasts (P90 percentile) for each service on the GPU inference platform, differentiating between holidays and workdays, with mutual fallback when historical samples are insufficient, and outputting results at both 10-minute and hourly time granularities.
Business Background and Objective: The GPU inference platform needs to forecast traffic and resource usage for each service over the next 14 days. The forecast is based on P90 percentile values from historical data, with differentiation between holidays and workdays. When historical samples for one category are insufficient, the other category is used as a fallback. The output includes forecast results at both 10-minute and hourly time granularities.
Input Tables (full name + brief description):
internal_platform_db.dwm_gputj_platform_gpu_base_feature_agg_v2_mysql_005(GPU feature aggregation fact table)internal_platform_db.dwd_aide_inferencev2_done_service_info_h_mysql_005(service list dimension table)internal_platform_db.dim_holiday_list_mysql_005(holiday dimension table)
(Please connect to the database and query to confirm the table structures and field semantics.)
Processing Rules:
- Fact table data range: Take partitions between
'20260420'and'20260507', excluding the anomalous period from'20260504'to'20260504'; traffic valuenv_inference_count_model_avg>= 0;agg_typeis 1 or 2. - Time point template: Extracted from the fact table partitions
'20260502'to'20260507'(exclusive). - Join logic:
- Cartesian product of the service list with all time points over the next 14 days (at 10-minute and hourly granularities).
- Join with the historical fact table on join keys:
service_name,agg_type, and the hour-minute portion of the time point. - Left join the holiday dimension table twice: once for the prediction date and once for the historical data date.
- Derived fields:
is_holiday: Whether the prediction date is a holiday (1/0).day_of_week: Day of the week for the prediction date (1–7).prediction_type: Fixed as'request_model_count'.statistic_time_count: Number of historical time points used in the forecast, computed using the holiday/workday mutual fallback logic.- P90 forecast fields: Based on the prediction day type (holiday/workday), take the P90 value of each metric from the corresponding historical data, with fallback to the other type when insufficient.
workload_name,namespace, etc.: Take the maximum value per service from the historical fact table.
Output Requirements:
- Output table:
internal_platform_db.dws_gputj_platform_model_prediction_long_p90_mysql_005 - Output fields (in order):
dt,instance_uuid,service_name,workload_name,namespace,agg_time,agg_type,is_holiday,day_of_week,prediction_type,nv_inference_count_model_avg_p90,statistic_time_count,nv_inference_request_duration_ms_model_avg,nv_inference_queue_duration_ms_model_avg,num_queued_reqs_model_avg,nv_inference_request_success_model_avg,nv_inference_request_failure_model_avg,nv_inference_request_duration_ms_perreq_avg,nv_inference_queue_duration_ms_perreq_avg,nv_inference_request_duration_ms_perreq_p95,nv_inference_queue_duration_ms_perreq_p95,nv_inference_request_success_model_max,nv_inference_request_failure_model_max,DCGM_FI_DEV_GPU_UTIL_pod_avg,k8s_container_bs_rate_cpu_core_used_request_pod_avg,k8s_container_rate_mem_working_set_request_pod_avg,k8s_dcgm_fi_dev_fb_util_pod_avg,k8s_container_vgpu_gpu_util_pod_avg - Write method: DELETE + INSERT or TRUNCATE + 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