How to map fields in Hive to export DynamoDb Amazon Console?

I am trying to load a DynamoDb export file that is taken from Amazon Dynamodb Web Console using the Import / Export tool in Hive. But I couldn’t display the fields correctly because the DynamoDB Web Console Export tool uses "ETX" "STX".

The following is an example of a line ending with [LF]

Elapsed[ETX]{"n":"1477"}[STX]Device[ETX]{"n":"3"}[STX]Date[ETX]{"s":"2014-03-05T12:13:00.852Z"}[STX]Duration[ETX]{"n":"8075"}[LF] 

What should be the request for this?

 CREATE EXTERNAL TABLE IF NOT EXISTS TableNameHere (creationDate string, device bigint, duration bigint, elapsed bigint) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' ???This is where i got stuck??? LOCATION 's3://abcdefg/ino/2015-05-28_12.22'; 

UPDATE

I have an updated request, but it did not work again.

'\ 002' for STX
'\ 012' for LF

 CREATE EXTERNAL TABLE IF NOT EXISTS TableNameHere (creationDate string, device bigint, duration bigint, elapsed bigint) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\002' LINES TERMINATED BY '\012' LOCATION 's3://abcdefg/ino/2015-05-28_12.22'; 

Result for the query:

 Elapsed{"n":"0"} Device{"n":"3"} Duration{"n":"1073876"} Date{"s":"2014-01-27T00:52:25.491Z"} 

So now, how can I parse this data? I need to display the fields. Should I use custom SerDe?

+5
source share
1 answer

I think there is already SerDe for this: https://github.com/lyft/dynamodb-hive-serde

+2
source

All Articles