Query staged ILOSTAT dataframes
ilostat_dataframe_queryRun a single-statement SELECT against the df_ dataframes staged by ilostat_query_indicator and ilostat_compare_geographies or stored by an earlier register_as. Inspect a dataframe with ilostat_dataframe_describe first; its column schema is what the SQL has to match. Read-only: writes, DDL, DROP, COPY, PRAGMA, ATTACH, and file-reading table functions are rejected, and system catalogs (information_schema, pg_catalog, sqlite_master, duckdb_*) are denied. Breakdown versions overlap (AGE_YTHADULT_*, AGE_AGGREGATE_*, AGE_10YRBANDS_*), so filter to one version before summing. Optional register_as stores the result as a new dataframe with a fresh TTL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One SELECT over df_<id> tables (DuckDB SQL: joins, aggregates, window functions, CTEs), at most 20,000 characters. BIGINT results such as COUNT or SUM of integers serialize as strings; CAST to DOUBLE for inline arithmetic. | |
| preview | No | Rows returned inline; defaults to row_limit. Set lower when register_as keeps the full result. | |
| row_limit | No | Hard cap on rows materialized (1–10,000). A query matching more stops at the cap and row_count_capped is true; register_as keeps the full result. | |
| register_as | No | Store the result as a new dataframe under this name (df_XXXXX_XXXXX: letters and digits, five in each part; stored uppercased after df_) with a fresh TTL, to chain analyses. A result over 1,000,000 rows is refused, and storing one can evict the oldest dataframes, which evicted names. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cap | No | The row cap that bound: preview when lower than row_limit, else row_limit. | |
| rows | No | Result rows keyed by the names in columns, bounded by preview and row_limit; BIGINT values arrive as strings. | |
| error | No | Present when the call failed. Absent on success. | |
| shown | No | Rows returned inline. | |
| notice | No | Guidance when the query returned no rows or a cap withheld some. | |
| columns | No | Column names in projection order. | |
| evicted | No | Dataframes dropped, oldest first, to keep this tenant within 1,000,000 staged rows and 100 dataframes; present only when storing the result evicted any. | |
| row_count | No | Rows the query produced. With register_as this is the exact count of the stored dataframe, which row_limit does not bound; otherwise at most row_limit, and when row_count_capped is true it is the cap, not a total. | |
| truncated | No | True when a cap withheld rows from this response. | |
| expires_at | No | ISO 8601 expiry of the new dataframe. | |
| registered_as | No | The new dataframe name, when register_as stored the result. | |
| row_count_capped | No | True when the query matched more rows than row_limit; never true with register_as, which stores every row. |