For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Source SQL

Use the physical data layer only for questions beyond the semantic model.

Source SQL runs warehouse SELECT statements against physical tables. Use it for direct warehouse access when the semantic layer does not expose the fields or expressions you need.

Endpoint: POST /api/v1/query/statement

{
  "sql": "SELECT store_region, COUNT(*) FROM retail.orders WHERE status = 'delivered' GROUP BY 1 LIMIT 100",
  "params": {},
  "meta": {}
}

Rules:

  • SELECT only. No INSERT, UPDATE, DELETE, or DDL.

  • Tables must exist in the active environment. Use Physical Table names from metadata (model.table.physical.name).

  • Write SQL in the gateway warehouse dialect (metadata.gateway.dialect, for example postgres). The API does not translate dialects for Source SQL.

  • Optional ?gateway= query parameter when multiple gateways are configured.

Response lifecycle

POST /api/v1/query/statement with { "sql": "...", "params": {}, "meta": {} } returns 202 Accepted and a statement id. Poll GET /api/v1/query/statement/{id} until status is SUCCESS or FAILED. Fetch rows from GET /api/v1/query/statement/{id}/result?format=json only after SUCCESS.

Status codes, deduplication, and export formats: see Query lifecycle.

Use Source SQL for ad-hoc access to Physical Tables, columns not exposed on the semantic layer, or expressions the semantic transpiler will not accept. Use the semantic layer when you need governed measures, segments, or cross-model joins.

Last updated

Was this helpful?