I have to populate data into a Hive table having timestamp as data-type.
Referring to other answers here I understand the method to create a new table with data type as string and then do the conversion to yyyy-mm-dd
as I have the format of mm/dd/yyyy
.
CREATE TABLE tbl_t (
t_id varchar(50),
c_date timestamp,
name varchar(25)
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t';
CREATE TABLE tbl_s (
t_id varchar(50),
c_date string,
name varchar(25)
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t';
I populated tbl_s with
aa 11/08/1994 hhh
ss 11/09/2011 bbb
mm 09/07/2000 qqq
select t_id
, from_unixtime(unix_timestamp(c_date ,'MM/dd/yyyy'),'yyyy-MM-dd')
, name
from tbl_s;
This works fine. Now I need to populate my orignal table. Using the query:
insert into table tbl_t
select t_id
, from_unixtime(unix_timestamp(c_date ,'MM/dd/yyyy'),'yyyy-MM-dd')
, name
from tbl_s;
and then
select * from tbl_t;
which returns
aa NULL hhh
ss NULL bbb
mm NULL qqq
Why are the timestamp columns null?