HiveQL 转换或同步以不同格式存储的日期类型

HiveQL converting or synchronizing date types stored in different formats

我正在尝试同步不同 table 中的两个时间指示器列以准备连接。问题是 db1 中的 date1 是没有尾随零的字符串格式,而 db2 中的 date2 是时间戳格式,但尾随零的日期没有小时或纳秒。我在下面显示变量。我怎样才能使两者同步?到目前为止,我已经尝试了一些建议,但没有成功。例如,当我对 date1 使用 cast as timestamp 转换时,对于没有时间信息的日期,我得到 null。我在下面的 table 列中显示示例数据。

date1 (string)

2017-05-13 11:46:12
2017-06-17
2017-05-19 05:34:52.78
2017-06-16 12:10:13.177
2017-05-25 05:32:05.99
2017-05-25 06:43:35.007
2017-05-13 11:45:47.873
2017-06-05

date2 (timestamp)

7/18/2013 18:08:48.000000
8/26/2015 00:00:00.000000
5/7/2015 20:03:25.000000
8/16/2014 12:08:48.000000
3/17/2017 11:05:52.530000
1/9/2014 21:11:49.000000
6/16/2016 14:22:40.157000
5/5/2017 14:12:48.497000

日期 1

with    t as 
        (
            select  explode
                    (
                        array
                        (
                            '2017-05-13 11:46:12'
                           ,'2017-06-17'
                           ,'2017-05-19 05:34:52.78'
                           ,'2017-06-16 12:10:13.177'
                           ,'2017-05-25 05:32:05.99'
                           ,'2017-05-25 06:43:35.007'
                           ,'2017-05-13 11:45:47.873'
                           ,'2017-06-05'
                        )
                    )   as date1
        )
select  cast(date1 as timestamp)
from    t
;

2017-05-13 11:46:12
2017-06-17 00:00:00
2017-05-19 05:34:52.78
2017-06-16 12:10:13.177
2017-05-25 05:32:05.99
2017-05-25 06:43:35.007
2017-05-13 11:45:47.873
2017-06-05 00:00:00

日期 2

with    t as 
        (
            select  explode
                    (
                        array
                        (
                            '7/18/2013 18:08:48.000000'
                           ,'8/26/2015 00:00:00.000000'
                           ,'5/7/2015 20:03:25.000000'
                           ,'8/16/2014 12:08:48.000000'
                           ,'3/17/2017 11:05:52.530000'
                           ,'1/9/2014 21:11:49.000000'
                           ,'6/16/2016 14:22:40.157000'
                        )
                    )   as date2
        )
select  cast(printf('%04d-%02d-%02d %s',int(d2[2]),int(d2[0]),int(d2[1]),d2[3]) as timestamp)
from    (select split(date2,'[/ ]') as d2 from t) t
;

2013-07-18 18:08:48
2015-08-26 00:00:00
2015-05-07 20:03:25
2014-08-16 12:08:48
2017-03-17 11:05:52.53
2014-01-09 21:11:49
2016-06-16 14:22:40.157