Slide 26
Slide 26 text
Copyright (C) 2022 Toranoana Lab Inc. All Rights Reserved.
サンプルコードと説明
メイン処理
● 分析用一時テーブルの作成
● Athena用のクエリを文字列で定
義
● サンプルでは、起動した時間の1
時間前のものをテーブル化
# CREATE文作成
query = "CREATE EXTERNAL TABLE IF NOT EXISTS waflog_temp(\n"
query += "`timestamp` bigint,\n"
# 中略
query = "ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'\n"
query = "LOCATION 's3://xxxxxxxxxxxxxxxxx/xxxx/%s/%s/%s/%s/';" % (
format(today.year, "04"),
format(today.month, "02"),
format(today.day, "02"),
format(today.hour - 1, "02"),
)
exec_athena_query(query, database, s3_output)