Stack 777
Stack 777

Reputation: 59

How to convert bigint to datetime in hive?

I had sqooped the data from teradata to Hive using sqoop import command.

For one of the tables in teradata, I have a date field . After sqooping, my date field is appearing as a timestamp with bigint datatype.

But I need the date field as a date datatype in hive table. Can anyone please suggest me in achieving this?

Upvotes: 3

Views: 19234

Answers (2)

danielsepulvedab
danielsepulvedab

Reputation: 674

I've had this problem. My approach was to create the Hive table first. You should make an equivalence between Teradata datatypes and your Hive version datatypes. After that you can use the Sqoop argument --hive-table <table-name> to insert into that table.

Upvotes: 1

sasi
sasi

Reputation: 364

select to_date(from_unixtime(your timestamp));

example:

select to_date(from_unixtime(1490985000));
output:2017-04-01

I hope it will work. please let me know if i am wrong.

Upvotes: 7

Related Questions