When querying athena using aws sdk, is it necessary to save results in s3?

1

I tried to do a select query on Athena using aws sdk.

In the sample, using resultconfiguration, it was stored in s3 and then queried.

However, it seems that the console showed the select result without saving the query result.

So I skipped resultconfiguration and ran aws sdk, and the following error occurred.

An output location is required either through the Workgroup result configuration setting or as an API input.

So I think that to query athena from aws sdk, the result must be saved in s3. Is this correct?

If not, please tell me how should I configure the aws sdk.

joker
질문됨 2년 전391회 조회
1개 답변
1
수락된 답변

Hello,

Amazon Athena automatically stores query results and metadata information for each query that runs in a query result location that you can specify in Amazon S3.

If necessary, you can access the files in this location to work with them. You can also download query result files directly from the Athena console.

To determine the location that Athena will use you need a combination of a workgroup and client-side settings.

The client-side settings are based on how you run the query:

If you run the query using the Athena console, the Query result location entered under Settings in the navigation bar determines the client-side setting.

If you run the query using the Athena API, the OutputLocation parameter of the StartQueryExecution action determines the client-side setting.

If you use the ODBC or JDBC drivers to run queries, the S3OutputLocation property specified in the connection URL determines the client-side setting.

To use the AWS CLI to identify the query output location and result files, run the aws athena get-query-execution command, as in the following example.

aws athena get-query-execution --query-execution-id <your-query-id>

Note: When you run a query using the API or using the ODBC or JDBC driver, the console setting does not apply.

For more detailed information, refer to Finding Query Output Files in S3.

I hope this helps.

Lunga T
답변함 2년 전
  • Does it work even if I don't specify the OutputLocation parameter in StartQueryExecution? It doesn't work in my case, so I'm wondering if I need to save the result to s3 when using the api.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠