github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/query_refer_table.md (about) 1 ### `query_refer_table()` {#fn-query-refer-table} 2 3 函数原型:`fn query_refer_table(table_name: str, key: str, value)` 4 5 函数说明:通过指定的 key 查询外部引用表,并将查询结果的首行的所有列追加到 field 中。该函数不适用于中心 Pipeline。 6 7 参数: 8 9 - `table_name`: 待查找的表名 10 - `key`: 列名 11 - `value`: 列对应的值 12 13 示例: 14 15 ```python 16 # 从输入中提取 表名,列名,列值 17 json(_, table) 18 json(_, key) 19 json(_, value) 20 21 # 查询并追加当前列的数据,默认作为 field 添加到数据中 22 query_refer_table(table, key, value) 23 24 ``` 25 26 示例结果: 27 28 ```json 29 { 30 "col": "ab", 31 "col2": 1234, 32 "col3": 123, 33 "col4": true, 34 "key": "col2", 35 "message": "{\"table\": \"table_abc\", \"key\": \"col2\", \"value\": 1234.0}", 36 "status": "unknown", 37 "table": "table_abc", 38 "time": "2022-08-16T15:02:14.158452592+08:00", 39 "value": 1234 40 } 41 ```