run_query
Execute read-only SELECT queries on ClickHouse, returning results as CSV. Optionally use snapshot mode for large datasets.
Instructions
[ClickHouse] Execute read-only SELECT or WITH … SELECT.
One statement; DML, DDL, SET, SYSTEM, and similar are rejected. Max-rows cap; overflow sets truncated and row_limit. Same SQL validation as analyze_query.
Returns {data, row_count} where data is an RFC 4180 CSV string.
Pass snapshot=true to persist the result to disk and receive a
{snapshot_uri, row_count} instead; fetch the CSV via the snapshot
resource URI.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | Read-only SELECT or WITH … SELECT. One statement; use qualified db.table or database. Driver placeholder syntax for parameters. | |
| profile | No | Profile name; uses default profile when omitted. Src: profiles. | |
| database | No | Session default database for unqualified names. Src: databases. | |
| snapshot | No | When true, persist the full result as a CSV file and return a resource URI (chx://snapshots/{id}) instead of inline data. Use for queries that may exceed the interactive row limit (1 000). Snapshot limits apply (default 10 000 rows, hard ceiling 50 000). Entries expire after 7 days. | |
| parameters | No | Named parameters for driver placeholders (e.g. %(name)s or {name:Type}). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |