Skip to content

Instantly share code, notes, and snippets.

@shiro01
Created October 15, 2018 09:21
Show Gist options
  • Save shiro01/4a07f9f5d3a47fd734264a9c8e862197 to your computer and use it in GitHub Desktop.
Save shiro01/4a07f9f5d3a47fd734264a9c8e862197 to your computer and use it in GitHub Desktop.
CSVファイル読み込むAthenaテーブル作成用CREATE文 (LazySimpleSerDe)
CREATE EXTERNAL TABLE IF NOT EXISTS test_db.test_table (
`test_date` date,
`test_id` string,
`test_num` int
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://test-bucket/test-folder/'
TBLPROPERTIES ('has_encrypted_data'='false');
-- Athenaのテーブル作成参考URL
-- CREATE TABLE:https://docs.aws.amazon.com/ja_jp/athena/latest/ug/create-table.html
--
-- CSVデータ形式を解析するためのライブラリ(SerDes)は以下の2つある
-- ・LazySimpleSerDe :https://docs.aws.amazon.com/ja_jp/athena/latest/ug/lazy-simple-serde.html
--  └データに引用符で囲まれた値が含まれていない場合
-- ・OpenCSVSerDe:https://docs.aws.amazon.com/ja_jp/athena/latest/ug/csv.html
--  └データの値に引用符が含まれているか、別の区切り文字やエスケープ文字が含まれている場合
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment