Guest User

Untitled

a guest
Apr 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. BUCKET = os.getenv('BUCKET', 'bucket')
  2.  
  3. def 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
Add Comment
Please, Sign In to add comment