gpt4 book ai didi

hadoop - HIVE 返回错误的日期

转载 作者:可可西里 更新时间:2023-11-01 16:44:21 25 4
gpt4 key购买 nike

我在处理日期时从 HIVE 得到了一些奇怪的结果。

对于初学者,我使用的是 Hive 1.2.1000.2.4.0.0-169

我有一个定义(剪断)的表格:

hive> DESCRIBE proto_hourly;
OK
elem string
protocol string
count bigint
date_val date
hour_id tinyint

# Partition Information
# col_name data_type comment

date_val date
hour_id tinyint
Time taken: 0.336 seconds, Fetched: xx row(s)
hive>

好的,我已经加载了当年的数据。我开始注意到特定日期查询中的一些“怪异”,但对于一个尖锐的例子,这是一个非常简单的查询,我只要求“2016-06-01”,但我得到了“2016-05-31”.. .为什么

hive> SET i="2016-06-01";
hive> with uniq_dates AS (
> SELECT DISTINCT date_val as date_val
> FROM proto_hourly
> WHERE date_val = date(${hiveconf:i}) )
> select * from uniq_dates;
Query ID = hive_20160616154318_a75b3343-a2fe-41a5-b02a-d9cda8695c91
Total jobs = 1
Launching Job 1 out of 1


Status: Running (Executing on YARN cluster with App id application_1465936275203_0023)

--------------------------------------------------------------------------------
VERTICES STATUS TOTAL COMPLETED RUNNING PENDING FAILED KILLED
--------------------------------------------------------------------------------
Map 1 .......... SUCCEEDED 1 1 0 0 0 0
Reducer 2 ...... SUCCEEDED 1 1 0 0 0 0
--------------------------------------------------------------------------------
VERTICES: 02/02 [==========================>>] 100% ELAPSED TIME: 3.63 s
--------------------------------------------------------------------------------
OK
2016-05-31
Time taken: 6.738 seconds, Fetched: 1 row(s)
hive>

最佳答案

再测试一下,我发现集群中有一个配置在不同时区的服务器。三个节点中有两个是 UTC,但一个节点仍在美国/丹佛。

我相信发生的事情是 Map/Reduce 作业在不同时区的服务器上执行,因此给我带来了奇怪的数据偏移问题。

日期 2016-06-01 UTC 确实等于日期 2016-05-31 America/Denver

静默 TZ 转换...

关于hadoop - HIVE 返回错误的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37864004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com