Hive的hour()函数返回12小时时钟值 [英] Hive's hour() function returns 12 hour clock value
问题描述
MySQLDateTime
字段作为我的Hive表中的时间戳
字段。任何人都知道问题可能是什么?我想我找到了它。我查看了源代码,显然 UDFHour.java
确实有两个 evaluate()
函数。一个接受 Text
对象作为参数,另一个使用 TimeStampWritable
对象作为参数。这两个函数都使用 Calendar
实例,但由于某种原因,第一个函数返回值 Calendar.HOUR_OF_DAY
,第二个函数 Calendar.HOUR
。
我查看了蜂巢文档,但找不到第二个函数的任何内容,但它在那里。我使用的Hive 0.9.0.16与Hortonworks的HDP一起提供。
编辑:
我已经报道过这个一段时间以前。现在有一个补丁: https://issues.apache.org/jira/browse/HIVE -3850 。
According to the documentation Hives standard function hour() should return a value between 0 and 24 but for some reason I always get a twelve hour clock value, between 0 and 12. I'm using a MySQLDateTime
field as a Timestamp
field in my Hive table. Anyone know what the problem might be?
I think I found it. I looked at the source code and apparently UDFHour.java
does have two evaluate()
functions. One that does accept a Text
object as parameter and one that uses a TimeStampWritable
object as parameter. Both work with a Calendar
instance but for some reason the first function returns the value of Calendar.HOUR_OF_DAY
and the second one Calendar.HOUR
.
I've looked in the Hives documentation but I couldn't find anything about that second function, but it's there. I'm using Hive 0.9.0.16, which came with Hortonworks' HDP.
Edit: I've reported this a while back. A patch is now available: https://issues.apache.org/jira/browse/HIVE-3850.
这篇关于Hive的hour()函数返回12小时时钟值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!