query_data
Run SQL queries on stored data tables, including full-text search, CTEs, joins, and window functions.
Instructions
Run SQL queries on tables stored via call_api's store_as parameter. Special commands: SHOW TABLES, DESCRIBE , DROP TABLE . Tables auto-expire after 1 hour. Supports CTEs, window functions, JOINs, and ILIKE.
Full-text search: any stored table with TEXT columns is searchable directly via FTS5. Use WHERE {table} MATCH 'query' and ORDER BY rank (lower = better). Numeric columns preserve their types. For long TEXT fields (news body, 10-K risk factors, filings) prefer snippet()/highlight() in SELECT instead of the raw column — full paragraphs can be thousands of tokens each.
Recommended FTS pattern:
Find matches compactly:
SELECT rowid, category, bm25({t}) AS score, snippet({t}, 4, '[', ']', '...', 15) AS snip FROM {t} WHERE {t} MATCH 'supply chain OR supplier' ORDER BY rankFetch the full body only for rows you need: call query_data again with
SELECT supporting_text FROM {t} WHERE rowid IN (2, 7)andmax_cell_chars=0.
Output cells over max_cell_chars (default 2000) are truncated with a visible marker; raise or set to 0 to disable.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL query or special command (SHOW TABLES, DESCRIBE <table>, DROP TABLE <table>) | |
| apply | No | List of function steps to post-process query results | |
| max_cell_chars | No | Truncate output cells whose string form exceeds this length, appending a '[truncated: N more chars]' marker. Default 2000. Set to 0 to disable (e.g. when fetching the full body of a specific row). Long TEXT columns like SEC filing text can be thousands of tokens each — prefer snippet()/highlight() in the SELECT list when searching. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |