dicemy's picture
Upload 655 files
e8c001c verified
|
Raw
History Blame Contribute Delete
2.72 kB
---
id: offline-compute_PrestoSQL_prestosql_005
name: Hot Table Governance Metadata Wide Table Aggregation
category: offline-compute/PrestoSQL
timeout_seconds: 900
modality: pure-text
engine: prestosql
---
## Prompt
**Task Objective**: From the hot table governance metadata detail table, filter valid hot table records (heat > 0, excluding temporary/test tables), aggregate by database name and table name to take the maximum of each metric, and write the results to the output table.
**Input Table**:
- `internal_platform_db.ads_gov_cost_table_govern_detail_df_prestosql_005` (hot table governance metadata detail table)
- `imp_date` BIGINT — date partition
- `db_name` STRING — database name
- `table_name` STRING — table name
- `heat` BIGINT — heat
- `owner` STRING — owner
- `storage_detail` DOUBLE — storage detail
- `task_cnt` BIGINT — task count
- `table_type` STRING — table type
- `govern_status` STRING — governance status
- `last_access_time` STRING — last access time
- `table_comment` STRING — table comment
- `partition_cnt` BIGINT — partition count
- `file_format` STRING — file format
- `table_size` DOUBLE — table size
- `avg_file_size` DOUBLE — average file size
- `is_partitioned` INT — whether partitioned
- `lifecycle_days` INT — lifecycle days
- `create_time` STRING — creation time
- `modify_time` STRING — modification time
- `project_name` STRING — project name
**Filter Conditions**:
- `imp_date = 20260507`
- `heat > 0`
- `table_name NOT LIKE '%temp%'`
- `db_name NOT LIKE '%test%'`
**Output Requirements**:
- Target table: `internal_platform_db.dwd_hot_metadata_table_cand_prestosql_005`
- Output fields and order: `dt` STRING, `db_name` STRING, `table_name` STRING, `owner` STRING, `storage_detail` DOUBLE, `heat` BIGINT, `task_cnt` BIGINT, `table_type` STRING, `govern_status` STRING, `last_access_time` STRING, `table_comment` STRING, `partition_cnt` BIGINT, `file_format` STRING, `table_size` DOUBLE, `avg_file_size` DOUBLE, `is_partitioned` INT, `lifecycle_days` INT, `create_time` STRING, `modify_time` STRING, `project_name` STRING
- `dt`: Fixed value `'20260507'`
- Group by `db_name`, `table_name`, apply `MAX()` to all other fields
- 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