select_schema
Pick the few tables and views a question needs as compact DDL for SQL, scoped to the caller so hidden objects and columns are excluded.
Instructions
Start here for any question about the data. Returns the few tables and views the question needs, as compact DDL to write SQL against, scoped to the caller: objects and columns they may not read are absent, not ranked low. Pass principal and roles whenever you know who is asking. Returns 'ddl' (put it in your SQL prompt), 'objects' (the names chosen), 'explain' (score and reason per object) and 'selected' / 'total_objects'. Reads table structure only, never rows. Next: write one SELECT against 'ddl' and call run_query with the same principal and roles; call describe_object if a table needs more columns than the compact DDL shows. If the right table is missing, raise top_k or rephrase rather than writing SQL against a table that was not returned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roles | No | The caller's roles or groups, e.g. ['finance', 'payroll']. Objects and columns restricted to a role are visible only when it is listed here. Omitted = no roles. | |
| top_k | No | How many tables and views to select for the question (default 6). Raise it for questions that span many areas; the caller's visible objects are the upper bound. | |
| question | Yes | The user's question in plain language, e.g. 'revenue by month' or 'which customers owe us money'. | |
| principal | No | Who is asking, as an identity string such as 'okta:jdoe'. Pass it whenever you know the user: visibility is decided for this identity. Omitted = anonymous, which sees only unrestricted objects. | |
| expand_foreign_keys | No | Also pull in tables joined by foreign key to the selected ones (default true), only where the caller may read them. Set false for the bare top matches. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |