Hive的hour()函数返回12小时时钟值 [英] Hive's hour() function returns 12 hour clock value

查看:949
本文介绍了Hive的hour()函数返回12小时时钟值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档Hives标准函数hour()应该返回一个0到24之间的值,但由于某种原因,我总是得到一个12小时的时钟值,介于0和12之间。我使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆