-
Notifications
You must be signed in to change notification settings - Fork 16
/
athena-queries.txt
47 lines (38 loc) · 1.08 KB
/
athena-queries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(Make sure to sync s3 bucket in the Amazon Athena settings prior)
1. Create Athena DB:
CREATE DATABASE IF NOT EXISTS athena_db;
2. Create table 1:
CREATE EXTERNAL TABLE IF NOT EXISTS athena_db.procedures (
`Procedure_ID` string,
`Procedure_Name` string,
`Category` string,
`Price` integer,
`Duration` integer,
`Insurance_Covered` string,
`Customer_Id` integer
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION 's3://genai-sourcedata-jo4/';
3. Create table 2:
CREATE EXTERNAL TABLE IF NOT EXISTS athena_db.customers (
`Cust_Id` integer,
`Customer_Name` string,
`Balance` integer,
`Past_Due` integer,
`Vip` string
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION 's3://genai-sourcedata-jo4/';
4. View table properties:
DESCRIBE athena_db.customers;
DESCRIBE athena_db.procedures;
4. Select all records:
SELECT procedure_id, procedure_name, category, price, duration, insurance_covered
FROM athena_db.procedures
WHERE insurance_covered = 'yes' OR insurance_covered = 'no';