github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/query_refer_table.en.md (about)

     1  ### `query_refer_table()` {#fn-query-refer-table}
     2  
     3  Function prototype: `fn query_refer_table(table_name: str, key: str, value)`
     4  
     5  Function description: Query the external reference table through the specified key, and append all the columns of the first row of the query result to field. This function does not work with central Pipeline.
     6  
     7  Function parameters:
     8  
     9  - `table_name`: the name of the table to be looked up
    10  - `key`: column name
    11  - `value`: the value corresponding to the column
    12  
    13  Example:
    14  
    15  ```python
    16  # extract table name, column name, column value from input
    17  json(_, table)
    18  json(_, key)
    19  json(_, value)
    20  
    21  # Query and append the data of the current column, which is added to the data as a field by default
    22  query_refer_table(table, key, value)
    23  
    24  ```
    25  
    26  Result:
    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  ```