--- id: offline-compute_PrestoSQL_prestosql_011 name: 安全平台PG敏感接口2表UNION+聚合 category: offline-compute/PrestoSQL timeout_seconds: 900 modality: pure-text engine: prestosql --- ## Prompt **任务目标**:将两个安全平台PG敏感接口数据表合并,排除黑名单域名后,按日期、域名和接口路径聚合,将匹配规则名拼接为逗号分隔字符串,写入输出表。 **输入表**:(2个表结构相同) - `internal_platform_db.internal_sec_radept_secpg_data_result2_prestosql_011` - `internal_platform_db.internal_sec_radept_secpg_data_result4_prestosql_011` 各表字段: - `databus_imp_date` INT — 数据日期 - `insert_time` STRING — 插入时间 - `src_ip` STRING — 源IP - `employeename` STRING — 员工名 - `http_host` STRING — 域名 - `http_cgi` STRING — 接口路径 - `http_param` STRING — 请求参数 - `http_user_agent` STRING — 用户代理 - `http_referer` STRING — 来源 - `http_body` STRING — 请求体 - `http_head` STRING — 请求头 - `httpsrsp_body` STRING — 响应体 - `httpsrsp_content_length` STRING — 响应内容长度 - `https_method` STRING — HTTPS方法 - `scan_group` STRING — 扫描组 - `rule_name` STRING — 规则名 - `match_string` STRING — 匹配字符串 - `match_type` STRING — 匹配类型 - `scan_comment` STRING — 扫描备注 **过滤条件**: - `databus_imp_date = 20260608` - `http_host NOT IN ('api.im-platform.example.com', 'mp.im-platform.example.com', 'open.im-platform.example.com', 'wx.im.example.com', 'wx2.im.example.com', 'wx8.im.example.com', 'web.im-platform.example.com', 'login.im-platform.example.com', 'long.open.im-platform.example.com', 'ext.im.example.com', 'proxy.svc.example.com', 'resolver.svc.example.com', 'cloud.provider.example.com', 'console.cloud.provider.example.com', 'csec.cloud.provider.example.com')` **输出要求**: - 目标表: `internal_platform_db.secpg_sensitive_interface_cand_prestosql_011` - 输出字段及顺序: `databus_imp_date` INT, `http_host` STRING, `http_cgi` STRING, `con_con` STRING - con_con: listagg(rule_name, ',') 或 array_join(array_agg(DISTINCT rule_name), ',') 聚合规则名 - 按 databus_imp_date, http_host, http_cgi 分组 - 如果目标表不存在,请先建表再写入数据 - 请使用Presto/Trino SQL语法,不要使用Hive/Spark SQL方言 **环境与执行说明**: - Presto已启动,通过Hive catalog连接 - 执行SQL: `presto-cli --catalog hive --schema internal_platform_db -f /tmp_workspace/result.sql` - 写出result.sql后,必须自己执行验证它能成功运行并产出正确数据