inspectQuery
inspectQueryParse SQL into an AST summary showing tables, aliases, joins, predicates, ordering, columns, and parameters—without requiring database access.
Instructions
Inspect SQL syntax and structure without accessing a database. Returns a parser-derived AST summary of tables, aliases, expressions, joins, predicates, ordering, columns and parameters; use validateQuery for driver validation or queryLint for metadata-aware advice.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| connection | Yes | Database to run against. Call listConnections for valid names; do not guess. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | ||
| joins | No | Join clauses detected in the query. | |
| tables | No | Table references extracted from the query, including CTEs and subqueries where possible. | |
| aliases | No | Map of SQL alias to referenced table or expression. | |
| columns | No | Column references extracted from all inspectable SQL clauses. | |
| explain | No | True when the inspected statement is an EXPLAIN statement. | |
| orderBy | No | ORDER BY expressions in the query. | |
| cteNames | No | Common table expression names declared by the query. | |
| features | No | ||
| warnings | No | Warnings produced while parsing and inspecting the query. | |
| parseable | No | True when SQL parsing succeeded well enough to produce structured inspection data. | |
| parameters | No | SQL placeholders or documented query parameters. | |
| predicates | No | Predicate expressions extracted from WHERE, JOIN, HAVING, and related scopes. | |
| selectItems | No | Expressions in the SELECT list, in output order. | |
| normalizedSql | No | Normalized SQL text produced by parser or usage-catalog indexing. | |
| statementType | No | Top-level SQL statement type detected by the parser. |