Athena

Reference: https://docs.aws.amazon.com/cli/latest/reference/athena/

Execute A Query

The query will be executed in the background.

aws athena start-query-execution \
  --work-group <WORK_GROUP_NAME> \
  --query-execution-context Database=<DATABASE_NAME> \
  --query-string <QUERY>

Example Response

{
    "QueryExecutionId": "8f54de09-e59d-4ef1-b738-af6ebc849f84"
}

The QueryExecutionId will be used to retrieve the query status and query results.

Retrieve the Query Status

aws athena get-query-execution --query-execution-id <QUERY_EXECUTION_ID>

Retrieve the Query Results

aws athena get-query-results --query-execution-id <QUERY_EXECUTION_ID>
  • You can "stream" the output by setting the --page-size <N> argument.

  • Or, you can paginate the results by setting the --max-items <N> and the --starting-token <NEXT_TOKEN> arguments, where the <NEXT_TOKEN> is obtained from the last get-query-results call.

Prepared Statement

Create the Prepared Statement

Execute the Prepared Statement

The prepared statement can be triggered by executing the EXECUTE query.

Retrieve the Prepared Statement

List the Prepared Statements

Last updated