I create an AWS lambda function with python 3.9 to run the Athena query and get the query result import time import boto3 # create Athena client client = boto3.client(‘athena’) # create Athena query varuable query = ‘select * from mydatabase.mytable limit 8’ DATABASE = ‘mydatabase’ output=’s3://mybucket/’ def lambda_handler(event, context): # Execution response = client.start_query_execution(… Read More Run aws Athena query by Lambda: error name 'response' is not defined
I have an array of unknown length in AWS Athena. I want to get all elements expect for the first one and concatenate into a string. I can do with a known length, but I don’t see how for unknown length. In this example: select this_arr, second, array_join(myslice, ‘ ‘) as myslice_joined from (select this_arr,… Read More how to get slice of an array in AWS Athena?
I am using AWS Athena (Presto based) and I have this table named base: id category year month 1 a 2021 6 1 b 2022 8 1 a 2022 11 2 a 2022 1 2 a 2022 4 2 b 2022 6 I would like a query that counts the distinct values of the categories… Read More SQL count distinct over partition by cumulatively
I would like to run a query like the following on Amazon Athena Select * from my_table where my_table.my_field like ‘%’sample_text’%’ I want to match the single quotes and the underscore in ‘sample_text’. I’ve tried variations of escape characters like \_, \\_, [_], `_, and `_` without success. Is this possible? >Solution : To escape… Read More How do you escape underscores and single quotes in Amazon Athena queries?