dicemy's picture
Upload 655 files
e8c001c verified
|
Raw
History Blame Contribute Delete
2.58 kB
metadata
id: offline-compute_HiveSQL_hivesql_007
name: >-
  Aggregate Notebook instance runtime statistics by trace_id and p_date for the
  day: Input table w
category: offline-compute/HiveSQL
timeout_seconds: 600
modality: pure-text
engine: hivesql

Prompt

Task Objective: Aggregate Notebook instance runtime statistics grouped by trace_id and p_date.

Input: internal_platform_db.dws_notebook_instance_execute_minute_stat_d_query_engine_019

  • Partition field: dt (STRING, format YYYYMMDD)
  • Key fields: trace_id, p_date, 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, code_gpu_count (numeric), used_gpu_count (numeric), is_code_running (INT), code_used_gpu_count (numeric)

Processing Rules:

  • Filter condition: dt = '20260507'
  • No joins, single-table processing
  • Aggregation: Group by trace_id, p_date
    • Most fields use MAX: 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
    • code_gpu_count: Use AVG
    • instance_gpu_util: AVG(used_gpu_count / code_gpu_count) * 100
    • code_gpu_util: AVG(IF(is_code_running = 1, code_used_gpu_count / code_gpu_count, NULL)) * 100

Output Requirements:

  • Output field order: dt (STRING), trace_id (STRING), p_date (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 (BOOLEAN), apply_for_gpu_count (INT), code_gpu_count (INT), instance_gpu_util (DOUBLE), code_gpu_util (DOUBLE)
  • Partition field: dt (STRING, format YYYYMMDD)

Write Requirements:

  • Target table: internal_platform_db.dws_notebook_instance_execute_stat_d_cand_query_engine_019
  • Write method: INSERT OVERWRITE partitioned by dt
  • If the target table does not exist, first create the table using standard Hive ORC storage, then write the data

Please write the final HiveSQL to result.sql and execute it.