run_sql
Run one read-only SQL query (SELECT, WITH, WITH RECURSIVE, UNION, window functions) in the DataFusion dialect (https://datafusion.apache.org/user-guide/sql/). DML, DDL, COPY, SET and EXPLAIN are rejected.
Use the table ids (tab-…) and column ids (col-…) describe_table returns, in double quotes. Column NAMES are NOT accepted.
JOINS: no bare CROSS JOIN. Check a result with unlinked_joins before reporting a number from it.
ARRAYS (list_string): array_has(list_col, needle) tests membership, in WHERE or as a JOIN predicate (list first; a membership link carries the exact join_predicate). UNNEST(list_col) in a CTE, then GROUP BY the element, aggregates across lists. An empty list is NULL and array_has(NULL, x) is NULL, so NOT array_has(...) silently drops untagged rows: use NOT COALESCE(array_has(col, x), false). An attachment column is NOT a list: it reads as one text value of file names; filter it with LIKE.
TIME: a - b on timestamps gives an interval AVG/SUM cannot use. Use mycorr_seconds_between(a, b) (Float64 seconds, any Date/Timestamp) or mycorr_days_between(a, b) (Int64 days, two Dates).
_row_id IS selectable and is the handle edit_rows takes; scan order is not row-id order, so ORDER BY when pairing ids across queries.
RESULTS: columns, rows, truncated (also set when a result is too large to hold), served. FLOAT/REAL are 32-bit: cast to DOUBLE.
join_fan_out means a join matched rows of one side more than once while something still depends on that side: confirm the key is unique, or aggregate that side first, before reporting a total. saveable means the result can be kept: create_table with sql writes it once into a new table when it reads one model's tables; create_recipe + materialize_recipe keep it refreshable.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sql": "<sql>"
},
"name": "run_sql"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One read-only SQL statement, tables and columns by id in double quotes (see the tool description). | |
| max_rows | No | Maximum result rows: default 10000, cap 100000. |