Tuesday, July 13, 2021

Athena Parameterized Query


Amazon Athena is an interactive query service that makes it easy to analyze data in Amazon S3 using standard SQL. Athena is serverless, so there is no infrastructure to manage, and you pay only for the queries that you run.

Recently, AWS worked on architecture improvements.  As the result, Amazon Athena leverages the re-usability, simplification, and security benefits of parameterized queries.

Last Thursday, analysts can save time and eliminate errors by converting queries that have frequently modified criteria, such as date filters or aggregation periods, into a parameterized query that serves multiple use cases. Application developers can use them to safeguard against SQL injection risks and simplify application integrations that generate SQL based on a user’s selections.

As an example, there is a query for retail sales metrics where the filters for product category, region, and date can vary from one execution to the next. Instead of manually modifying the logic in your SQL code each time you run the query, you can use variables for product category, region, and date whose values are provided when executing the query.

Parameterized query is available in SELECT and INSERT INTO queries through the Athena console, API, and SQL clients using Athena’s ODBC or JDBC drivers. Ref: https://docs.aws.amazon.com/athena/latest/ug/querying-with-prepared-statements.html

No comments:

Post a Comment