【发布时间】:2019-08-08 11:21:21
【问题描述】:
我在生产环境(cloudera 5.5)中的 hive 中面临一个非常奇怪的问题,这在我的本地服务器中基本上无法重现(不知道为什么),即对于某些记录,我在从临时表插入时时间戳值错误到主表作为字符串“2017-10-21 23”在插入时转换为时间戳“2017-10-21 23:00:00”数据类型。
例子::
2017-10-21 23 -> 2017-10-21 22:00:00
2017-10-22 15 -> 2017-10-22 14:00:00
这种情况很少发生。 表示增量值约为数据的 1%。
Flow::: 临时表(外部表)中的数据使用 oozie 每小时填充一次。下面的插入语句每小时执行一次,使用 Oozie 工作流从临时表插入到 hive 中的主表(ORC 中的内部表)。
流程摘要::: Linux日志>>在临时表中复制日志(外部配置单元表)>>插入主配置单元表中。
从临时表插入主表:::
FROM
temp
INSERT INTO TABLE
main
PARTITION(event_date,service_id)
SELECT
from_unixtime(unix_timestamp(event_timestamp ,'yyyy-MM-dd HH'), 'yyyy-MM-dd HH:00:00.0'),
col3,
col4,
"" as partner_nw_name,
col5,
"" as country_name,
col6,
col7,
col8,
col9,
col10,
col11,
col12,
col13,
col14,
col15,
kpi_id,
col18,
col19,
col20,
col21,
col23,
col24,
col25,
from_unixtime(unix_timestamp(event_timestamp ,'yyyy-MM-dd HH'), 'yyyy-MM-dd') as event_date,
service_id;
临时表:::
hive> desc temp;
OK
event_timestamp string
col2 int
col3 int
col4 int
col5 int
col6 string
col7 string
col8 string
col9 string
col10 string
col11 int
col12 int
col13 string
col14 string
col15 string
service_id int
kpi_id int
col18 bigint
col19 bigint
col20 bigint
col21 bigint
col22 double
col23 string
col24 int
col25 int
Time taken: 0.165 seconds, Fetched: 25 row(s)
主表:::
hive> desc main;
OK
event_timestamp timestamp
col3 int
col4 int
partner_nw_name string
col5 int
country_name string
col6 string
col7 string
col8 string
col9 string
col10 int
col11 int
col12 int
col13 string
col14 string
col15 string
kpi_id int
col18 bigint
col19 bigint
col20 bigint
col21 bigint
col23 double
col24 int
col25 int
event_date date
service_id int
# Partition Information
# col_name data_type comment
event_date date
service_id int
Time taken: 0.175 seconds, Fetched: 32 row(s)
【问题讨论】:
标签: hive hiveql cloudera cloudera-cdh