Run Queries using CLI on Athena Tables

Today, I will discuss about Athena APIs which can be used in automation using shell scripting to fetch the Table data to perform validations like count, date, sum (aggregate functions), duplicate .I will explain the APIs using count validation in Athena. Get the Total records Details of the Athena tables using Athena APIs.STEP 1 : Use the below Command to get the query execution id for count Query of particular Table.API Used : start-query-executionaws athena start-query-execution –query-string “SELECT count(*) FROM $S3-Schema.$S3-Table” | grep [a-z] |awk -F “:” ‘{print $2}’|sed -e…

Athena object properties

Today, I will discuss about the two things in single blog.1. How to generate DDL of Athena Object2. How to Check the properties of tables . GENERATE DDL of Athena ObjectLook at left Pane in the Athena console, select the database, Click on three vertical dots. See the below ScreenShot for the same. Click on “Generate Create Table DDL“ Table Properties of Athena Object Go to “Show Properties“ Once you click on Show properties. You will see the below Screen .If you can see , it will tell you when…

create database in Athena

Today , I will discuss about “How to create Database in Athena.Follow the below steps to achieve the same.* Create IAM policy which gives access to S3 bucket for Athena Logs to the required user.* While creating that IAM policy, you need to put the below content in the JSON tab.* Here, in below JSON, you need to change the bucket Name. * If you see clearly , in JSON both Glue and Athena has mentioned , so if you don’t want to give access to Glue DB, then you…