-
Execute
SHOW TABLES;
to get list of all tables in selected database. -
SELECT * FROM
each of the tables in above list. -
Store table-wise json files (as per the format required by AWS Athena) in a temporary folder (named
data
) - Push stored files to S3.
- Delete the temporary folder with its contents.
- Repair the tables created in AWS Athena.
- Create an S3 bucket with the name S3_BUCKET and region S3_REGION
- Create a folder named query-result inside the root folder of the bucket, with the absolute path as ATHENA_OUTPUT_LOCATION
- Recommended: use Athena old console
- For creating new Athena DB, make sure region is same as S3_REGION
- Connect Data Source → S3, Glue → Create New Database (name should be ATHENA_DB) → Create Table in Athena → Add columns of any one table with datatype
- Run all
CREATE EXTERNAL TABLE
queries linking each table's location tos3://<S3_BUCKET>/<TABLE_NAME>
.
- It is imperative that each folder corresponding to a table has the absolute path
s3://<S3_BUCKET>/<TABLE_NAME>
.