--- id: offline-compute_HiveSQL_hivesql_023 name: Compute multi-dimensional CUBE aggregation of user open-start-path data by referer_type, referer, and path category: offline-compute/HiveSQL timeout_seconds: 600 modality: pure-text engine: hivesql --- ## Prompt Task Objective: Compute multi-dimensional aggregation metrics from the user open-start-path detail table, outputting UV and first-time UV across three dimension combinations: application category (`referer_type`), source application (`referer`), and launch path (`path`). Inputs: - `internal_platform_db.t_ed_mapservice_user_open_start_path_dwd_di_query_engine_135` - `internal_platform_db.t_ed_mapservice_user_q36_active_dwd_di_query_engine_135` Processing Rules: 1. Main table filter: `ds=20260608`, and `referer` must be in the specified lists of application package names/keys for three categories (FoodChainA, QuickDog, JD). 2. Path cleansing: Process the `path` field according to rules — if it matches `qqmap://map/routeplan?type=\w+`, retain the original value; if it contains `?`, truncate to the part before the question mark; if it is empty/null/`'NULL'`, set it to `'未知'`; otherwise, retain the original value. 3. `referer_type` mapping: Map the `referer` value to one of three categories: `'FoodChainA'`, `'CourierCoB'` (QuickDog), or `'EcommerceC'` (JD). 4. Join: Join with `t_ed_mapservice_user_q36_active_dwd_di_query_engine_135` (`ds=20260608`, `uin` deduplicated) on `uin`, retaining active users. 5. Aggregation: Group by `referer_type`, `CUBE(referer, path)`, computing `count(distinct uin)` as `uv` and `count(distinct case when is_first=1 then uin end)` as `first_uv`. 6. CUBE result processing: For dimensions where `grouping` is 1, set the value to `'total'`. Output Requirements: - Field order: `referer_type`, `referer`, `path`, `uv`, `first_uv`, `ds` - `referer` and `path` display as `'total'` on CUBE summary rows - `uv` is of type BIGINT, `first_uv` is of type BIGINT Write Requirements: - Output table: `internal_platform_db.t_md_mapservice_user_open_start_path_dwa_di_cand_query_engine_135` - Partition: `ds=20260608` - Write method: `INSERT OVERWRITE` Please write the final HiveSQL to `result.sql` and execute it.