Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

hive create table having timestamp with timezone data type in Athena

avatar
Frequent Visitor

I tried to find solution that fits my use case and tried many things, but failed.

Please help me. Thank you in advance.

 

I have input in following format:

12, 2019-07-08 00:02:54.436062+00

23, 2019-07-08 00:48:41.23138+00

..

 

how do i create table with timestamp datatype for 2nd column. Please don't suggest regexSerDe. (because this is dummy example, my test string is very complex)

In all my input data, all values in 2nd col have '+00' in the end. So, I don't even have to convert to any timezone, i can just skip last 3 characters when parsing. Is there any way to do that?

What I have tried

 

CREATE EXTERNAL TABLE test (

  id int,

  ts timestamp)

ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
)

LOCATION 's3://user/'

 

1 ACCEPTED SOLUTION

avatar
Frequent Visitor

Solved it using,

CREATE EXTERNAL TABLE test (

  id int,

  ts timestamp)

ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',

"timestamp.formats"="yyyy-MM-dd HH:mm:ss.SSSSSS+00"
)

LOCATION 's3://user/'

View solution in original post

1 REPLY 1

avatar
Frequent Visitor

Solved it using,

CREATE EXTERNAL TABLE test (

  id int,

  ts timestamp)

ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',

"timestamp.formats"="yyyy-MM-dd HH:mm:ss.SSSSSS+00"
)

LOCATION 's3://user/'