Synchronous call from AWS Lambda to Athena

Punter Vicky

I am looking to query data in my S3 buckets using Athena from my AWS Lambda. When I looked at some of the examples the call from Lambda to Athena seems to be asynchronous. The Lambda makes a call to Athena and waits for Athena to write the results to S3 bucket. Is there a way to directly retrieve the response instead of having to write it to a S3 bucket?

Theo

There is not. Athena will always write the results to S3 (even with the new semi-private "streaming" API that is used by the JDBC driver). The only way to know when an Athena query is completed is to poll using the GetQueryExecution API call. Even seemingly synchronous APIs like the JDBC driver use this method internally.

However, there is no need to read the response from S3, there is also the GetQueryResults API call that returns the result along with type information. If there are less that 1000 rows in the response or performance is not the top priority it's a better way to retrieve the results than reading the CSV file from S3.

If you're using Athena from Lambda my suggestion is to look at Step Functions. Unless your Athena queries never run more than a few seconds you can save a lot of money by building a simple state machine that executes the query. You can find a good blueprint in the job poller sample project.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

AWS Secrets Manager call from Lambda returning null/none

分類Dev

AWS lambda fails to call Facebook SDK

分類Dev

How to query in AWS athena connected through S3 using lambda functions in python

分類Dev

AWS lambda layers error when call API "cannot find module"

分類Dev

Setting http response header from AWS lambda

分類Dev

Setting http response header from AWS lambda

分類Dev

Aws Athena - Rename column name

分類Dev

AWS Athena JDBC Query timeout

分類Dev

AWS Athena ODIJDBC接続

分類Dev

AWS Athena ODIJDBC接続

分類Dev

AWS Athena create table and partition

分類Dev

Wrapping synchronous code into asynchronous call

分類Dev

Run queries in AWS Athena from boto3 gives bad permissions

分類Dev

Publish mqtt message to topic from aws lambda using aws iot

分類Dev

running aws athena query via pyathena

分類Dev

AWS Athena 및 date_format

分類Dev

Possible to Specify a Parameter For AWS Athena Query?

分類Dev

AWS QuickSight can't see Athena DB

分類Dev

AWS Athena - duplicate columns due to partitionning

分類Dev

AWS Athena ALIAS in Group By does not get resolved

分類Dev

Dynamic js bundle synchronous api call

分類Dev

Managing synchronous XHR/Ajax call in AngularJs

分類Dev

Access AWS S3 from Lambda within VPC

分類Dev

Access AWS S3 from Lambda within VPC

分類Dev

Access AWS S3 from Lambda within VPC

分類Dev

Can not use zip from S3 for AWS Lambda

分類Dev

SIGSEGV from spawn child_process in AWS Lambda function

分類Dev

Setting Cookie in http response header from AWS lambda Node JS

分類Dev

accessing origin URL from AWS lambda@edge