我需要插入两列当前日期(sysdate)和时间戳。 我创建了表并使用unix_timestamp插入数据。我无法转换为hive日期和时间戳格式。
############ Hive create table #############
create table informatica_p2020.M23_MD_LOC_BKEY(
group_nm string,
loc string,
natural_key string,
loc_sk_id int,
**load_date date,
load_time timestamp)**
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION '/user/spanda20/informatica_p2020/infor_external/m23_md_loc/m23_md_loc_bkey/';
############### Insert into Table ##########
insert overwrite table M23_MD_LOC_BKEY select 'M23' as group_nm,loc,concat('M23','|','LOC') as NATURAL_KEY,
ROW_NUMBER() OVER () as loc_sk_id,
from_unixtime(unix_timestamp(), 'YYYY-MM-DD'),
from_unixtime(unix_timestamp(), 'YYYY-MM-DD HH:MM:SS.SSS') from M23_MD_LOC LIMIT 2 ;
################output of the insert query ############
M23 SY_BP M23|LOC 1 **2015-07-183** 2015-07-**183** 16:07:00.000
M23 SY_MX M23|LOC 2 2015-07-183 2015-07-183 16:07:00.000
此致 Sanjeeb
答案 0 :(得分:0)
而不是from_unixtime(unix_timestamp(),' YYYY-MM-DD ') 尝试 - from_unixtime(unix_timestamp(),' yyyy-MM-dd ')