Reputation: 39
I have query execution id for a certain Athena query. I want to get the Output Location for this query. I know I can fetch the results using query execution id from java aws sdk. I have created athena client object named 'athenaClient' of class AmazonAthena using my credentials of aws.
GetQueryResultsRequest getQueryResultsRequest = new
GetQueryResultsRequest().withExecutionId(execId);
GetQueryResultsResult getQueryResultsResult =
athenaClient.getQueryResults(getQueryResultsRequest);
Using this getQueryResultsResult, I can fetch the query results. But I want to get the Output Location through Athena query execution id.
Upvotes: 0
Views: 1510
Reputation: 2088
Hi i create a simple API SDK that you can found on
https://github.com/fulmicotone/aws-java-athena-helper
every improvement is welcome thanks
MyAthena.Builder.standard(ATHENA_DEFAULT_DATABASE,ATHENA_OUTPUT_BUCKET)
.build()
.newQuery(ATHENA_SAMPLE_QUERY)
.submit()
.waitForQueryToComplete()
.processResultRows(5, new Consumer<AthenaPageResults>() {
@Override
public void accept(AthenaPageResults athenaPageResults) {
System.out.println("page:"+athenaPageResults.getPage());
}
});
Upvotes: 0
Reputation: 14039
I'm not that deep into the Java SDK, but the location of the result can be retrieved through the getQueryExecution
method.
So it should be something like this:
GetQueryExecutionResult result = athenaClient.getQueryExecution(GetQueryExecutionRequest().withExecutionId(execId));
QueryExecution exec = result.getQueryExecution();
ResultConfiguration config = exec.getResultConfiguration();
ResultConfiguration - AWS Java SDK
Upvotes: 3