fusion_validate_query
Validate free SQL against trusted ground truth to confirm query correctness. Supply expectations or a fixture, and get a full diff of every mismatch for targeted repair.
Instructions
Validate free SQL -- ONLY on a pod that substitutes lexical parameters.
Same engine as fusion_validate_report, pointed at a statement instead of a
registered report. It therefore inherits fusion_run_query's limitation: on a
pod with lexical substitution disabled the statement never reaches the
database (SELECT * FROM (), ORA-00903), and the response hint says so.
Use fusion_validate_report instead there -- validating a registered
report's output is the path that works, and validation is the point of this
server.
Where free SQL does run, this is what turns "the query ran" into "the query is correct". Supply the facts the user already trusts -- a total read off the Fusion UI, a known document number, an exported spreadsheet -- and every expectation is evaluated (never short-circuited) so one round trip tells you everything that is wrong.
Read the diff on failure; it is a repair signal, not just a verdict. A
unique_key failure means join fan-out. An expected row that is absent means
either the WHERE is too tight or Fusion row-level Data Security hides it from
the service account -- add a broadened cross_check COUNT(*) to tell those
apart before rewriting the query.
Two honest limits: a passing fixture proves consistency with the ground truth supplied, not universal correctness (use at least two independent expectation types); and results reflect what the single service account is allowed to see.
Args:
sql: The SELECT statement to validate.
expectations: Inline expectation objects. Mutually exclusive with fixture.
fixture: Name of a saved fixture to validate against.
datasource: Configured datasource key.
max_rows: Row cap for the validation run; keep it above the expected count.
timeout_s: Per-call timeout in seconds.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| fixture | No | ||
| max_rows | No | ||
| timeout_s | No | ||
| datasource | No | ||
| expectations | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||