Execute an SQL statement
Read published reference data with an SQL SELECT statement. Unlike the per-table filter endpoints, one statement can read several tables and join them on a condition of your choosing. The statement field describes the currently supported SQL.
This endpoint only reads data and never modifies it. Only SELECT statements are accepted. A statement reads the latest published version of each table it names. All tables are read from one consistent snapshot, even if a publish completes while the statement runs.
The response contains either the complete result or an error. Results are never truncated. A response holds at most 10000 rows: if the result would be larger, the statement is rejected, so add a LIMIT of 10000 or fewer, or narrow the statement. A LIMIT above 10000 is rejected before the statement runs, even if the statement would have returned fewer rows than that. A statement is also rejected if the response, or a single value in it, would be too large to return, or if the statement runs too long.
Check meta.next to see whether the response holds the whole result: when it is present, the result continues beyond this response. A result that does not fit within these limits is rejected rather than split across responses, so narrow the statement instead. meta.total is not returned.
A problem with the statement itself returns 400 Bad Request: invalid syntax, an unknown column, an unsupported construct, an evaluation error such as division by zero or a failed cast, a timeout, or a result that exceeds a size limit. The detail field explains the reason and, where applicable, names the size limit or the line and column in the statement. detail is a human-readable message: its wording can change, and no field in the response identifies the specific cause.
Your API client needs read permission on every table the statement names. If the request has no valid token, or the statement names a table you cannot read, the whole statement fails with 403 Forbidden. A table that does not exist returns the same 403 with the same detail as a table you cannot read, so the two cases are intentionally indistinguishable. Do not treat them differently.
Request
- Base URLhttps://your-environment.ataccama.one/api
- AuthHTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"statement": "SELECT c.country_code AS code,\n c.country_name AS name,\n r.region_name AS region\nFROM Countries c\nLEFT JOIN Regions r ON c.region_code = r.region_code\nWHERE c.population > 1000000\nLIMIT 100\n"
}Response
The statement's result.
Example response
{
"meta": {
"next": "MjA=",
"total": 150,
"columns": [
{
"name": "region",
"dataType": "STRING"
}
]
}
}Changes
No recorded changes to this operation across all 1 revision of this API.