Query Treasury Dataframes
treasury_dataframe_queryRun a single-statement SELECT against DataCanvas dataframes registered by treasury_query_dataset, treasury_get_debt, treasury_get_interest_rates, and treasury_get_exchange_rates. Read-only: writes, DDL, DROP, COPY, PRAGMA, ATTACH, and external-file table functions are rejected. System catalogs (information_schema, pg_catalog, sqlite_master, duckdb_*) are denied at the bridge layer. All Treasury dataframe columns are VARCHAR — CAST to DECIMAL or DATE for arithmetic and date comparisons. Use treasury_dataframe_describe to list available table names and column schemas before querying.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | Single-statement SELECT against df_<id> tables. All values in Treasury dataframes are VARCHAR (strings) per the API contract — CAST to DECIMAL or DATE for arithmetic and date comparisons. Example: SELECT record_date, CAST(tot_pub_debt_out_amt AS DECIMAL) AS debt FROM df_xxxxx ORDER BY record_date DESC LIMIT 10. | |
| preview | No | Rows in the immediate response. Defaults to row_limit and may not exceed it. Set lower when using register_as. | |
| row_limit | No | Hard cap on rows the query may produce. Default 1000, max 10000. A query matching more rows than this stops at the cap and row_count_capped comes back true — raise it, or use register_as to materialize the whole result. | |
| register_as | No | Persist the result as a new dataframe under this exact name, to chain analyses. The name is used verbatim — any name works, and a df_ prefix keeps it consistent with the tables the data tools mint. Echoed back in registered_as. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cap | No | The row cap that was applied — preview when supplied, otherwise row_limit. | |
| rows | No | Materialized rows, bounded by preview / row_limit. | |
| error | No | Present when the call failed. Absent on success. | |
| shown | No | Number of rows returned in this response. | |
| notice | No | Guidance when the query returned no rows, or when results were capped by preview or row_limit. | |
| columns | No | Column names in projection order. | |
| row_count | No | Rows the query produced, up to row_limit. Exceeds rows.length when preview returned fewer. Read with row_count_capped: when that is true this number is row_limit itself, and the size of the full result is not in this response. | |
| truncated | No | True when the returned rows were capped below the full result set. | |
| expires_at | No | ISO 8601 expiry timestamp for the newly registered dataframe, when applicable. | |
| registered_as | No | Set when register_as was supplied and the new dataframe was materialized. | |
| row_count_capped | No | True when the query matched more rows than row_limit, so row_count is that cap rather than a total. False means row_count is exact — including when it happens to equal row_limit. |