| --- |
| id: offline-compute_HiveSQL_hivesql_006 |
| name: Input Table internal_platform_db.ods_t_databus_access_topic |
| category: offline-compute/HiveSQL |
| timeout_seconds: 600 |
| modality: pure-text |
| engine: hivesql |
| --- |
| ## Prompt |
| Task Objective: Cleanse the 数据总线 topic access cost raw data and aggregate it by topic dimension, excluding test topics, then write the results to a detail table. |
|
|
| Input: `internal_platform_db.ods_t_databus_access_topic_cost_date_d_query_engine_015`, partitioned by field `dt` (STRING, YYYYMMDD). Key fields: `systemname`, `dwproductname`, `dwappgroup`, `cityid`, `iset`, `topic`, `data_size` (BIGINT), `total_cost` (DOUBLE), `in_charge`. |
|
|
| Processing Rules: No joins, single-table processing. Filter condition: `dt = '20260507' AND topic <> 'test'`. Aggregation: Group by `topic`, applying `MAX` to `systemname`, `dwproductname`, `dwappgroup`, `cityid`, `iset`, `data_size`, `total_cost`, and `in_charge`. Derived column: `dt` directly takes the partition value `'20260507'`. |
|
|
| Output Requirements: The output field order is `dt`, `system_belong`, `category_name`, `dw_appgroup`, `city_id`, `cluster_set`, `topic`, `total_data_size_d`, `total_cost`, `in_charge`. Field mappings: `dt=dt`, `system_belong=MAX(systemname)`, `category_name=MAX(dwproductname)`, `dw_appgroup=MAX(dwappgroup)`, `city_id=MAX(cityid)`, `cluster_set=MAX(iset)`, `topic=topic`, `total_data_size_d=MAX(data_size)`, `total_cost=MAX(total_cost)`, `in_charge=MAX(in_charge)`. Data types: `dt` STRING, `system_belong` STRING, `category_name` STRING, `dw_appgroup` STRING, `city_id` STRING, `cluster_set` STRING, `topic` STRING, `total_data_size_d` BIGINT, `total_cost` DOUBLE, `in_charge` STRING. |
|
|
| Write Requirements: Target table `internal_platform_db.dwd_databus_topic_cost_detail_d_cand_query_engine_015`. Table comment: "数据总线 topic access cost detail table, including access cost and dimension information, performing data cleansing on the ODS layer." Partition field `dt` (STRING, YYYYMMDD). Write method: `INSERT OVERWRITE`, overwriting the partition `dt='20260507'`. If the target table does not exist, first create the table using standard Hive ORC storage format partitioned by `dt`, then write the data. |
|
|
| Please write the final HiveSQL to `result.sql` and execute it. |
|
|