[英]How do I get the data scanned by an Athena query using the aws-java-sdk version 1?
I'm using the aws-java-sdk version 1.11.573 to make calls to Athena to execute queries using Groovy:我正在使用 aws-java-sdk 版本 1.11.573 调用 Athena 以使用 Groovy 执行查询:
def queryExecutionContext = new QueryExecutionContext().withDatabase(AthenaConstants.ATHENA_DATABASE)
def resultConfiguration = new ResultConfiguration().withOutputLocation("s3://${resultBucket}")
def startQueryExecutionRequest = new StartQueryExecutionRequest()
.withQueryString(query)
.withQueryExecutionContext(queryExecutionContext)
.withResultConfiguration(resultConfiguration)
def startQueryExecutionResult = amazonAthena.startQueryExecution(startQueryExecutionRequest)
def queryExecutionId = startQueryExecutionResult.getQueryExecutionId()
def queryStatusRequest = new GetQueryExecutionRequest().withQueryExecutionId(queryExecutionId)
Awaitility.await("Athena query ${queryExecutionId}")
.pollInterval(new org.awaitility.Duration(pollingPeriod.toMillis(), TimeUnit.MILLISECONDS))
.atMost(timeout.toMillis(), TimeUnit.MILLISECONDS)
.until { hasQuerySucceeded(queryStatusRequest) }
def getQueryResultsRequest = new GetQueryResultsRequest().withQueryExecutionId(queryExecutionId)
GetQueryResultsResult getQueryResultsResult = amazonAthena.getQueryResults(getQueryResultsRequest)
List<Row> results = getQueryResultsResult.getResultSet().getRows()
And I would like to get the amount of data scanned so that I can log it as a metric so that it can be easily monitored.我想获得扫描的数据量,以便我可以将其记录为指标,以便可以轻松监控。
I believe it is pretty straightforward to do with gversion 2, but I can't really upgrade at the moment.我相信使用 gversion 2 非常简单,但我目前无法真正升级。
Does anyone know how to get that metric?有谁知道如何获得该指标?
Thanks!谢谢!
Java V1 is not the recommended way to use the SDK. Java V1 不是使用 SDK 的推荐方式。 However, you can refer to this very old example here:但是,您可以在此处参考这个非常古老的示例:
https://github.com/aws-doc-sdk-examples/blob/main/java/example_code/athena/src/main/java/aws/example/athena/StartQueryExample.java https://github.com/aws-doc-sdk-examples/blob/main/java/example_code/athena/src/main/java/aws/example/athena/StartQueryExample.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.