Search code examples
amazon-web-servicesbatch-processingamazon-athenaaws-java-sdk

Execute A set of queries as Batch In AW Athena


I'm trying to execute AWS Athena queries as batch using aws-java-sdk-athena. I'm able to establish the connection,run individually the queries, but no idea how to run 3 queries as batch. Any help appreciated.

Query

 1.select * from table1 limit 2
 2.select * from table2 limit 2
 3.select * from table3 limit 2

Solution

  • You can run multiple queries in parallel in Athena. They will be executed in background. So if you start your queries using e.g.

    StartQueryExecutionResult startQueryExecutionResult = client.startQueryExecution(startQueryExecutionRequest);
    

    you will get an executionId. This can be then used to query the status of the running queries to check if they finished already. You can get the execution status of the query using getQueryExecutionId or batchGetQueryExecution.

    Limits

    There are some limits in Athena. You can run up to 20 SELECT queries in parallel.

    See documentation:

    20 DDL queries at the same time. DDL queries include CREATE TABLE and CREATE TABLE ADD PARTITION queries.

    20 DML queries at the same time. DML queries include SELECT and CREATE TABLE AS (CTAS) queries.