Skip to content

SQL query

The SQL query capability allows an agent to answer natural-language questions using data from a connected relational database. The agent identifies a relevant data source and tables, generates a query for the database’s SQL dialect, and returns the results as a Dataset that can be viewed as an interactive table.

The capability is only available to agents with the SQL query permission, and it can only use relational data sources available through the user’s configured connections.

StageWhat DataQI does
Data source selectionIdentifies a relevant connected database and the tables needed to answer the question.
Query generationInstructs the language model to generate one read-only SELECT query using only the supplied table and column schemas.
Static validationParses the generated SQL for the database dialect and rejects queries that cannot be shown to be a single read-only query, including known unsafe statements, locking operations and functions.
ExecutionApplies a timeout and row limit, executes the accepted query inside a transaction, and automatically rolls the transaction back.
ResultsStores the point-in-time results as a Dataset for display and further analysis, and are available as a CSV export.

If a generated query is rejected or fails, the agent can attempt one correction. A query that remains invalid is not executed again.