Datasets:
id: offline-compute_PrestoSQL_prestosql_006
name: News Plugin Send Process Multi-Dimensional Aggregation
category: offline-compute/PrestoSQL
timeout_seconds: 900
modality: pure-text
engine: prestosql
Prompt
Task Objective: From the news plugin send process flow table, aggregate and compute metrics such as send count, send UV, panel exposure count, panel exposure UV, inner-page PV, and inner-page UV by the scene (pos_desc) dimension, across two time windows — current day and last 1 hour — and write the results to the output table.
Input Table:
internal_platform_db.dwm_news_plugin_ai_assistant_send_process_flow_hi_prestosql_006(news plugin send process flow table)imp_hourBIGINT — hourly partitionuser_idSTRING — user IDcontent_idSTRING — content IDpush_idSTRING — push IDposSTRING — positionsend_cntBIGINT — send countpanel_exp_cntBIGINT — panel exposure countpgin_pvBIGINT — inner-page PVpos_descSTRING — position description (scene)account_codeSTRING — business code
Output Requirements:
Target table:
internal_platform_db.ads_news_plugin_ai_assistant_hourly_report_cand_prestosql_006Output fields and order:
imp_hourBIGINT — hourly partitionsceneSTRING — scene (pos_desc)send_cnt_dthBIGINT — current day send count (SUM(send_cnt) WHERE imp_hour <= current hour)send_uv_dthBIGINT — current day send UV (COUNT(DISTINCT user_id) WHERE imp_hour <= current hour)panel_exp_cnt_dthBIGINT — current day panel exposure count (SUM(panel_exp_cnt) WHERE imp_hour <= current hour)panel_exp_uv_dthBIGINT — current day panel exposure UV (COUNT(DISTINCT user_id) WHERE panel_exp_cnt > 0 AND imp_hour <= current hour)pgin_pv_dthBIGINT — current day inner-page PV (SUM(pgin_pv) WHERE imp_hour <= current hour)pgin_uv_dthBIGINT — current day inner-page UV (COUNT(DISTINCT user_id) WHERE pgin_pv > 0 AND imp_hour <= current hour)send_cnt_1hBIGINT — last 1 hour send count (SUM(send_cnt) WHERE imp_hour = current hour)send_uv_1hBIGINT — last 1 hour send UVpanel_exp_cnt_1hBIGINT — last 1 hour panel exposure countpanel_exp_uv_1hBIGINT — last 1 hour panel exposure UVpgin_pv_1hBIGINT — last 1 hour inner-page PVpgin_uv_1hBIGINT — last 1 hour inner-page UV
Simplified explanation: For each
imp_hour+pos_desccombination, compute the current day cumulative (dth) and current hour (1h) aggregation metricsIf 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