我有2张桌子
CREATE TABLE table1(
ctn string
, platform_code string
, status string
, status_date date
)
PARTITIONED BY(time_key string)
STORED AS ORC;
和
CREATE TABLE table2(
time_key timestamp
, ctn string
, platform_code string
, status string
, status_date timestamp
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\;'
STORED AS TEXTFILE;
在table1中,我有一些数据。实施例
(9056697563,C,,,2017-09-22)
status
为空字符串,status_date
为null
。我需要在将2017-09-22转换为时间戳时插入此行。我试试这个时
SELECT from_unixtime(unix_timestamp(time_key, 'yyyy-MM-dd')) AS time_key
, ctn
, platform_code
, status
, from_unixtime(unix_timestamp(time_key, 'yyyy-MM-dd')) AS status_date
FROM table1
WHERE time_key = '2017-09-22';
time_key
和status_date
都有值2017-09-22 00:00:00
,但是当我尝试时
INSERT OVERWRITE TABLE table2
SELECT from_unixtime(unix_timestamp(time_key, 'yyyy-MM-dd')) AS time_key
, ctn
, platform_code
, status
, from_unixtime(unix_timestamp(time_key, 'yyyy-MM-dd')) AS status_date
FROM table1
WHERE time_key = '2017-09-22';
time_key
以null
结束,status_date
结束为2017-09-22 00:00:00
为什么会这样?
修改
我删除了AS time_key
和AS status_date
后,它正常运行。有人知道为什么吗?