

# 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](API_StartQueryExecution.md) to run a query.

## Request Syntax
<a name="API_GetQueryResultStream_RequestSyntax"></a>

```
{
   "QueryExecutionId": "{{string}}",
   "Range": "{{string}}"
}
```

## Request Parameters
<a name="API_GetQueryResultStream_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [QueryExecutionId](#API_GetQueryResultStream_RequestSyntax) **   <a name="athena-GetQueryResultStream-request-QueryExecutionId"></a>
The unique ID of the query execution.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 128.  
Pattern: `\S+`   
Required: Yes

 ** [Range](#API_GetQueryResultStream_RequestSyntax) **   <a name="athena-GetQueryResultStream-request-Range"></a>
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
<a name="API_GetQueryResultStream_ResponseSyntax"></a>

```
{
   "AcceptRanges": "string",
   "Body": blob,
   "ContentRange": "string",
   "ContentType": "string"
}
```

## Response Elements
<a name="API_GetQueryResultStream_ResponseElements"></a>

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](#API_GetQueryResultStream_ResponseSyntax) **   <a name="athena-GetQueryResultStream-response-AcceptRanges"></a>
Indicates the server accepts byte-range requests. Value: `bytes`.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 256.

 ** [Body](#API_GetQueryResultStream_ResponseSyntax) **   <a name="athena-GetQueryResultStream-response-Body"></a>
The raw binary stream of query result data.  
Type: Base64-encoded binary data object

 ** [ContentRange](#API_GetQueryResultStream_ResponseSyntax) **   <a name="athena-GetQueryResultStream-response-ContentRange"></a>
The content range for partial responses (HTTP 206).  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 256.

 ** [ContentType](#API_GetQueryResultStream_ResponseSyntax) **   <a name="athena-GetQueryResultStream-response-ContentType"></a>
The MIME type of the result data.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 256.

## Errors
<a name="API_GetQueryResultStream_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** 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 `Range` header 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
<a name="API_GetQueryResultStream_Examples"></a>

### Example: Downloading query results in byte ranges from Amazon Athena
<a name="API_GetQueryResultStream_Example_1"></a>

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:

```HTTP
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
<a name="API_GetQueryResultStream_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/athena-2017-05-18/GetQueryResultStream) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/athena-2017-05-18/GetQueryResultStream) 