getQueryResults method

Future<GetQueryResultsOutput> getQueryResults({
  1. required String queryExecutionId,
  2. int? maxResults,
  3. String? nextToken,
})

Streams the results of a single query execution specified by QueryExecutionId from the Athena query results location in Amazon S3. For more information, see Query Results 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.

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.

Implementation

Future<GetQueryResultsOutput> getQueryResults({
  required String queryExecutionId,
  int? maxResults,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(queryExecutionId, 'queryExecutionId');
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    1000,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    1024,
  );
  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,
    },
  );

  return GetQueryResultsOutput.fromJson(jsonResponse.body);
}