Datasets:
metadata
id: offline-compute_PrestoSQL_prestosql_002
name: Ad ASA Attribution Migration
category: offline-compute/PrestoSQL
timeout_seconds: 900
modality: pure-text
engine: prestosql
Prompt
Task Objective: From the ad attribution raw logs, filter valid records of two attribution types (ad_attribution and huawei), aggregate the log count and deduplicated user count by version and media dimensions, and write the results to the output table.
Input Table:
internal_platform_db.t_sh_event_log_v2_06000061157_prestosql_002(ad attribution raw logs)ftimeSTRING — timeextinfoSTRING — extended informationad_versionSTRING — ad version (ad_attribution/huawei)guidSTRING — user identifierchSTRING — channelfirst_dateSTRING — first datelast_dateSTRING — last dateclick_dateSTRING — click dateattributionSTRING — attribution flagconversion_dateSTRING — conversion dateconversion_typeSTRING — conversion typecreativeset_idSTRING — creative set IDorg_idSTRING — organization IDcampaign_idSTRING — campaign IDadgroup_idSTRING — ad group IDkeyword_idSTRING — keyword IDcountry_oregionSTRING — country/regionenter_ag_timeSTRING — ad group entry timeinstalled_finish_timeSTRING — installation completion timestart_download_timeSTRING — download start timesub_channelSTRING — sub-channelcallbackSTRING — callback informationtask_idSTRING — task IDsub_task_idSTRING — sub-task IDrta_idSTRING — RTA identifierdevice_idSTRING — device_id identifierext_info1STRING — extended information 1ext_info2STRING — extended information 2caidSTRING — CAIDclaim_typeSTRING — claim typeai_assistant_device_idSTRING — YB device_iddsSTRING — partition field
Filter Conditions:
ds = '2026060919'- Valid record condition:
(ad_version = 'ad_attribution' AND attribution = 'true') OR (ad_version = 'phonebrandh' AND callback != '')
Output Requirements:
- Target table:
internal_platform_db.t_my_ads_tracking_log_metrics_cand_prestosql_002 - Output fields and order:
dsBIGINT,ad_versionSTRING,media_idINT,log_numBIGINT,log_num_qimeiBIGINT ds: Cast the original table'sdsfield to BIGINTmedia_id:CASE ad_version WHEN 'ad_attribution' THEN 39 WHEN 'phonebrandh' THEN 28 ENDlog_num:COUNT(*)log countlog_num_qimei:COUNT(DISTINCT device_id)deduplicated user count- Group by
ds,ad_version - 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