GetQueryResultStream
Returns query results as a raw binary stream for a single query execution specified by
QueryExecutionId. Streams the raw result data in Apache Arrow
Inter-Process Communication (IPC) Stream format without transformation.
Use StartQueryExecution to run a query.
Request Syntax
{
"QueryExecutionId": "string",
"Range": "string"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- QueryExecutionId
-
The unique ID of the query execution.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
\S+Required: Yes
- Range
-
An optional byte range header. Format:
bytes=N-M. When specified, returns HTTP 206 with the requested byte slice.Type: String
Length Constraints: Minimum length of 0. Maximum length of 256.
Pattern:
^bytes=[0-9]+-[0-9]*$Required: No
Response Syntax
{
"AcceptRanges": "string",
"Body": blob,
"ContentRange": "string",
"ContentType": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- AcceptRanges
-
Indicates the server accepts byte-range requests. Value:
bytes.Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
- Body
-
The raw binary stream of query result data.
Type: Base64-encoded binary data object
- ContentRange
-
The content range for partial responses (HTTP 206).
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
- ContentType
-
The MIME type of the result data.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
Errors
For information about the errors that are common to all actions, see Common Error Types.
- InternalServerException
-
Indicates a platform issue, which may be due to a transient condition or outage.
HTTP Status Code: 500
- InvalidRequestException
-
Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.
- AthenaErrorCode
-
The error code returned when the query execution failed to process, or when the processing request for the named query failed.
HTTP Status Code: 400
- RangeNotSatisfiableException
-
The byte range specified in the
Rangeheader cannot be satisfied for the query result. Returned with HTTP status code 416.- Message
-
A message describing why the requested range cannot be satisfied.
HTTP Status Code: 416
- TooManyRequestsException
-
Indicates that the request was throttled.
- Reason
-
The reason for the query throttling, for example, when it exceeds the concurrent query limit.
HTTP Status Code: 400
Examples
Example: Downloading query results in byte ranges from Amazon Athena
Request byte ranges to download large result sets in parts or to resume an interrupted download. The response body is a slice of the Apache Arrow stream. The following HTTP request and response show a request for the first 1,024 bytes of the results of a query execution:
GET /query-executions/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111/result-stream HTTP/1.1 Host: athena.aa-example-3.amazonaws.com X-Amz-Date: 20261201T120000Z X-Amz-Security-Token: AQoDYXdzEXAMPLETOKEN Authorization: AWS4-HMAC-SHA256 Credential=ASIAIOSFODNN7EXAMPLE/20261201/aa-example-3/athena/aws4_request, SignedHeaders=host;range;x-amz-date;x-amz-security-token, Signature=EXAMPLE1234567890abcdef1234567890abcdef1234567890abcdef12345678 Range: bytes=0-1023 HTTP/1.1 206 Partial Content Content-Type: application/vnd.apache.arrow.stream Content-Range: bytes 0-1023/773720 Accept-Ranges: bytes [binary Apache Arrow stream data]
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: