dicemy's picture
Upload 655 files
e8c001c verified
|
Raw
History Blame Contribute Delete
4.57 kB
metadata
id: offline-compute_PrestoSQL_prestosql_012
name: Data Quality Check Pipeline Instance GPU Card-Hour Analysis
category: offline-compute/PrestoSQL
timeout_seconds: 900
modality: pure-text
engine: prestosql

Prompt

Task Objective: Analyze the runtime of data quality check pipeline instances. For some abnormally terminated instances, their completion records need to be backfilled. Compute the runtime duration of each instance per date shard, and combined with GPU monitoring data, compute the GPU card-hour consumption, ultimately outputting a detail table.

Business Background: The data quality check pipeline produces various span records, including check.start, check.completed, check.aborted, data.scan, rule.evaluate, resource.allocate, etc. Some instances only record check.aborted without check.completed. For these instances, a synthetic check.completed record must be constructed based on their start and aborted times to correctly compute the runtime duration.

GPU monitoring data is collected in 5-minute windows and must be mapped to instances via Pod names. Combined with the GPU count from the task configuration, the card-hours are computed (gpu_hour = host_gpu_num * total_run_minutes / 60.0).

Input Tables:

  • internal_platform_db.t_quality_check_span_prestosql_012 (quality check span table)

    • databus_imp_date STRING — data date
    • trace_id STRING — trace ID
    • span_name STRING — span name
    • start_time STRING — start time (epoch milliseconds)
    • end_time STRING — end time (epoch milliseconds)
    • status_code INT — status code
    • project_id STRING — project ID
    • task_id STRING — task ID
    • check_type STRING — check type
  • internal_platform_db.t_quality_gpu_monitor_prestosql_012 (GPU monitoring table)

    • pod_name STRING — Pod name
    • pkg_time STRING — collection time (epoch seconds)
    • gpu_name STRING — GPU model
    • metric STRING — monitoring metric
    • value STRING — metric value
    • dt STRING — date partition
  • internal_platform_db.dwd_quality_podname_prestosql_012 (Pod-to-instance mapping table)

    • dt STRING — date partition
    • instance_uuid STRING — instance UUID
    • pod_name STRING — Pod name
    • pod_phase STRING — Pod phase
  • internal_platform_db.dwd_quality_task_config_prestosql_012 (task GPU configuration table 1)

    • databus_imp_date STRING — data date
    • instance_uuid STRING — instance UUID
    • host_gpu_num DOUBLE — GPU count
    • host_num DOUBLE — host count
    • last_modify DOUBLE — last modification time
    • gpu_name STRING — GPU model
    • resource_id STRING — resource ID
    • is_dedicated STRING — whether dedicated
  • internal_platform_db.quality_task_config_prestosql_012 (task GPU configuration table 2)

    • databus_imp_date STRING — data date
    • instance_uuid STRING — instance UUID
    • host_gpu_num DOUBLE — GPU count
    • host_num DOUBLE — host count
    • last_modify DOUBLE — last modification time
    • gpu_name STRING — GPU model
    • resource_id STRING — resource ID
    • is_dedicated STRING — whether dedicated
    • scan_type STRING — scan type

Key Logic Notes:

  1. Identify trace_ids that have only check.aborted without check.completed, and synthesize a check.completed record for them
  2. Spans running across days must be split by day, generating one record per day
  3. GPU monitoring data must be deduplicated by 5-minute windows to compute running minutes, and mapped to instances via Pod mapping
  4. The two GPU configuration tables must be combined with UNION ALL, then use ROW_NUMBER to take the latest configuration per instance
  5. gpu_hour = host_gpu_num * total_run_minutes / 60.0

Output Requirements:

  • Target table: internal_platform_db.t_quality_check_gpu_instance_detail_cand_prestosql_012
  • Output fields: p_date STRING, trace_id STRING, project_id STRING, task_id STRING, check_type STRING, status_code INT, instance_run_time INT, code_run_time INT, gpu_hour DOUBLE, resource_id STRING, is_dedicated BOOLEAN
  • If the target table does not exist, first create the table, then write the data
  • Use Presto/Trino SQL syntax; do not use Hive/Spark SQL dialects

Environment and Execution Notes:

  • Presto is running, connected via the Hive catalog
  • Execute SQL: presto-cli --catalog hive --schema internal_platform_db -f /tmp_workspace/result.sql
  • After writing result.sql, you must execute it yourself to verify that it runs successfully and produces correct data