javav2/example_code/athena/src/main/java/aws/example/athena/StartQueryExample.java
/**
     * Submits a sample query to Athena and returns the execution ID of the query.
     */
Submits a sample query to Athena and returns the execution ID of the query.
Submits a sample query to Athena and returns the execution ID of the query .
private static String submitAthenaQuery(AthenaClient athenaClient) {
        QueryExecutionContext queryExecutionContext = QueryExecutionContext.builder()
                .database(ExampleConstants.ATHENA_DEFAULT_DATABASE).build();
        ResultConfiguration resultConfiguration = ResultConfiguration.builder()
                .outputLocation(ExampleConstants.ATHENA_OUTPUT_BUCKET).build();
        StartQueryExecutionRequest startQueryExecutionRequest = StartQueryExecutionRequest.builder()
                .queryString(ExampleConstants.ATHENA_SAMPLE_QUERY)
                .queryExecutionContext(queryExecutionContext)
                .resultConfiguration(resultConfiguration).build();
        StartQueryExecutionResponse startQueryExecutionResponse = athenaClient.startQueryExecution(startQueryExecutionRequest);
        return startQueryExecutionResponse.queryExecutionId();
    }
private static String submitAthenaQuery ( AthenaClient athenaClient ) { QueryExecutionContext queryExecutionContext = QueryExecutionContext . builder ( ) . database ( ExampleConstants . ATHENA_DEFAULT_DATABASE ) . build ( ) ; ResultConfiguration resultConfiguration = ResultConfiguration . builder ( ) . outputLocation ( ExampleConstants . ATHENA_OUTPUT_BUCKET ) . build ( ) ; StartQueryExecutionRequest startQueryExecutionRequest = StartQueryExecutionRequest . builder ( ) . queryString ( ExampleConstants . ATHENA_SAMPLE_QUERY ) . queryExecutionContext ( queryExecutionContext ) . resultConfiguration ( resultConfiguration ) . build ( ) ; StartQueryExecutionResponse startQueryExecutionResponse = athenaClient . startQueryExecution ( startQueryExecutionRequest ) ; return startQueryExecutionResponse . queryExecutionId ( ) ; }
Submits a sample query to Athena and returns the execution ID of the query.
Submits a sample query to Athena and returns the execution ID of the query .
// The QueryExecutionContext allows us to set the Database. // The result configuration specifies where the results of the query should go in S3 and encryption options // You can provide encryption options for the output that is written. // .withEncryptionConfiguration(encryptionConfiguration) // Create the StartQueryExecutionRequest to send to Athena which will start the query.