Created
July 21, 2021 03:42
-
-
Save GarimaDamani/b2cf2a9a37ea392145ad975396374765 to your computer and use it in GitHub Desktop.
Create a table schema in the database for parsing s3 logs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE s3_access_logs_db; | |
CREATE EXTERNAL TABLE `s3_access_logs_db.mybucket_logs`( | |
`bucketowner` STRING, | |
`bucket_name` STRING, | |
`requestdatetime` STRING, | |
`remoteip` STRING, | |
`requester` STRING, | |
`requestid` STRING, | |
`operation` STRING, | |
`key` STRING, | |
`request_uri` STRING, | |
`httpstatus` STRING, | |
`errorcode` STRING, | |
`bytessent` BIGINT, | |
`objectsize` BIGINT, | |
`totaltime` STRING, | |
`turnaroundtime` STRING, | |
`referrer` STRING, | |
`useragent` STRING, | |
`versionid` STRING, | |
`hostid` STRING, | |
`sigv` STRING, | |
`ciphersuite` STRING, | |
`authtype` STRING, | |
`endpoint` STRING, | |
`tlsversion` STRING) | |
ROW FORMAT SERDE | |
'org.apache.hadoop.hive.serde2.RegexSerDe' | |
WITH SERDEPROPERTIES ( | |
'input.regex'='([^ ]*) ([^ ]*) \\[(.*?)\\] ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (\"[^\"]*\"|-) (-|[0-9]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (\"[^\"]*\"|-) ([^ ]*)(?: ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*))?.*$') | |
STORED AS INPUTFORMAT | |
'org.apache.hadoop.mapred.TextInputFormat' | |
OUTPUTFORMAT | |
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' | |
LOCATION | |
's3://awsexamplebucket1-logs/prefix/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment