Skip to content

query_data

Execute a read-only SQL query via DuckDB against data sources for a project. Supports two source types: (1) Uploaded files (upload_data) — table name is the source_name given at upload. (2) Google Sheet snapshots (connect_google_sheet) — each tab becomes its own table named {source_name}_{tab_name} where non-alphanumeric characters in the tab name are replaced with underscores (e.g. source ‘budget’, tab ‘Q1 Revenue’ → table ‘budget_Q1_Revenue’). FRESHNESS: Google Sheet results reflect the latest snapshot captured by connect_google_sheet. Call connect_google_sheet again to refresh before querying when current data is needed. The snapshot_taken_at field in the sources response shows when each sheet was last snapshotted. Only SELECT and WITH statements are accepted. Results are capped at row_limit rows (default 1 000, max 10 000). Returns: columns (list[str]) — ordered column names; rows (list[list]) — result rows as JSON-serialisable values; row_count (int) — number of rows returned; truncated (bool) — true when row_limit was reached; sources (list) — loaded sources with fields: source_name, source_type, tables (list of DuckDB table names), snapshot_taken_at (ISO 8601 UTC or null); warnings (list[str], optional) — present when Google Sheet tabs were skipped due to empty or malformed CSV snapshots.

NameTypeRequiredDefaultDescription
project_namestrYes
sqlstrYes
row_limitintNo1000

Returns a structured object. Top-level fields:

  • columns (array<string>)
  • rows (array<array<string>>)
  • row_count (integer)
  • truncated (boolean)
  • sources (array<object>)

See the response example below for the full payload shape.

{
"name": "query_data",
"arguments": {
"project_name": "forecasts",
"sql": "SELECT month, revenue FROM actuals ORDER BY month LIMIT 3",
"row_limit": 1000
}
}
{
"columns": [
"month",
"revenue"
],
"rows": [
[
"2026-01-01",
100.0
],
[
"2026-02-01",
110.0
],
[
"2026-03-01",
121.0
]
],
"row_count": 3,
"truncated": false,
"sources": [
{
"source_name": "actuals",
"source_type": "parquet",
"tables": [
"actuals"
],
"snapshot_taken_at": null
}
]
}
  • Module: Data
  • Requires authentication via API token or Auth0 JWT.