· 8 years ago · Apr 23, 2018, 09:14 AM
1BUCKET = os.getenv('BUCKET', 'bucket')
2
3def init_schema(event, context):
4 db = get_results(f"""
5 CREATE DATABASE IF NOT EXISTS mydb
6 LOCATION 's3://{BUCKET}/';
7 """)
8
9 table = get_results(f"""
10 CREATE EXTERNAL TABLE IF NOT exists users (
11 id STRING,
12 first_name STRING,
13 last_name STRING,
14 birthday STRING
15 )
16
17 ROW FORMAT serde 'org.openx.data.jsonserde.JsonSerDe'
18 with serdeproperties ( 'paths'='id, first_name, last_name, birthday' )
19 LOCATION 's3://{BUCKET}/';
20 """)
21
22 return db, table