get_query_results¶
- PlaygroundApi.get_query_results(queryid, role_id, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)¶
Get query results
Returns the result rows of a query. The query must have reached SUCCEEDED, otherwise the request is rejected with GE-1095, and the caller must be the user who submitted it. This operation is a preview, not a full export: the backend caps the response at 51 rows and there are no pagination parameters. Use ResultsDownloadLink, or GET /queries/{queryid}/results/download, to retrieve the complete result file. Statements that produce no result set (CREATE, MERGE INTO, VACUUM) return a synthetic single-column result whose Header is [“Message”] and whose single row carries the confirmation text, with no ResultsDownloadLink. Note that an unknown query id is reported as HTTP 400 with IPV-1002, not 404.
- Parameters:
queryid (str) – Identifier of the query whose results are being read. (required)
role_id (str) – Amorphic role ID the request is authorized against. Must be a role the caller belongs to. (required)
_request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.
_request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.
_content_type (str, Optional) – force content-type for the request.
_headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.
_host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.
- Return type:
- Returns:
Returns the result object.
Request and Response Examples¶
HTTP: GET /queries/{queryid}/results
Parameter examples¶
Name |
In |
Example |
|---|---|---|
|
path |
|
|
header |
|
Success (HTTP 200)¶
Result preview, capped at 51 rows. TotalNumRows is present on the Redshift path only.
Athena result set, all cells returned as strings
{
"Header": [
"order_id",
"customer",
"amount"
],
"Rows": [
[
"1001",
"acme",
"250.00"
],
[
"1002",
"globex",
"75.50"
]
],
"ResultsDownloadLink": "https://s3.amazonaws.com/bucket/results/query.csv?X-Amz-Signature=..."
}
Redshift result set, cells keep their source type and TotalNumRows is present
{
"TotalNumRows": 1284,
"Header": [
"order_id",
"customer",
"amount",
"is_paid"
],
"Rows": [
[
1001,
"acme",
250.0,
true
],
[
1002,
"globex",
null,
false
]
],
"ResultsDownloadLink": "https://s3.amazonaws.com/bucket/results/query.csv?X-Amz-Signature=..."
}
CREATE statement, which returns a message rather than rows
{
"Header": [
"Message"
],
"Rows": [
[
"Table created successfully"
]
]
}
Errors¶
Documented error codes: IPV-1002, AUTH-1010, GE-1095, AUTH-1001, AUTH-1030, GE-1060, GE-1034, RTE-1001.
HTTP 400
Input validation or authorization failure. Body is {“Message”: “<CODE> - <text>”}. Codes: IPV-1002 (query id not found), AUTH-1010 (the query belongs to a different user), GE-1095 (the query has not reached SUCCEEDED), AUTH-1001 / AUTH-1030 / GE-1060 (authorization).
Query has not finished successfully
{
"Message": "GE-1095 - No query results available for download. Please try again after some time."
}
Unknown query id
{
"Message": "IPV-1002 - Invalid QueryId - b1e6c2a0-9f4d-4c7a-8f2e-1a2b3c4d5e6f, resource not found."
}
Query belongs to another user
{
"Message": "AUTH-1010 - User is not authorized to perform this operation"
}
HTTP 500
Backend failure, including the case where the stored result location is missing for a successful query (GE-1034). Body is {“Message”: “<CODE> - <text>”}.
Request / response example
{
"Message": "RTE-1001 - <exception details>"
}