getQueryResults method
Streams the results of a single query execution specified by
QueryExecutionId from the Athena query results location in
Amazon S3. For more information, see Working
with query results, recent queries, and output files in the Amazon
Athena User Guide. This request does not execute the query but returns
results. Use StartQueryExecution to run a query.
To stream query results successfully, the IAM principal with permission to
call GetQueryResults also must have permissions to the Amazon
S3 GetObject action for the Athena query results location.
May throw InternalServerException.
May throw InvalidRequestException.
May throw TooManyRequestsException.
Parameter queryExecutionId :
The unique ID of the query execution.
Parameter maxResults :
The maximum number of results (rows) to return in this request.
Parameter nextToken :
A token generated by the Athena service that specifies where to continue
pagination if a previous request was truncated. To obtain the next set of
pages, pass in the NextToken from the response object of the
previous page call.
Parameter queryResultType :
When you set this to DATA_ROWS or empty,
GetQueryResults returns the query results in rows. If set to
DATA_MANIFEST, it returns the manifest file in rows. Only the
query types CREATE TABLE AS SELECT, UNLOAD, and
INSERT can generate a manifest file. If you use
DATA_MANIFEST for other query types, the query will fail.
Implementation
Future<GetQueryResultsOutput> getQueryResults({
required String queryExecutionId,
int? maxResults,
String? nextToken,
QueryResultType? queryResultType,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
1000,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonAthena.GetQueryResults'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'QueryExecutionId': queryExecutionId,
if (maxResults != null) 'MaxResults': maxResults,
if (nextToken != null) 'NextToken': nextToken,
if (queryResultType != null) 'QueryResultType': queryResultType.value,
},
);
return GetQueryResultsOutput.fromJson(jsonResponse.body);
}