【问题标题】:display date only once [elegant way] in Hive在 Hive 中仅显示一次日期 [优雅方式]
【发布时间】:2013-07-23 11:24:17
【问题描述】:

如何使用内置的Date and Time functions 只显示一次日期

mysql中我们可以通过select curdate();来获取

+------------+
| curdate()  |
+------------+
| 2013-07-23 |
+------------+

Hive 中尝试 select unixtime(); 会得到 FAILED: ParseException line 1:17 mismatched input '<EOF>' expecting FROM near ')' in from clause

做,select from_unixtime(unix_timestamp(),"yyyy-MM-hh") from abc.xyz LIMIT 1;给我

OK
2013-07-03

我的预期输出,但对我来说使用随机数据库及其表仅用于访问date 似乎并不明智。这样做的正确方法是什么?

【问题讨论】:

    标签: hadoop hive cloudera hiveql


    【解决方案1】:

    目前,Hive 不支持在不读取任何其他表的情况下构造行(这是您在运行 select curdate()select curdate() from dual 时尝试执行的操作)。

    这是work in progress

    【讨论】:

    • 谢谢。这很有帮助。
    【解决方案2】:

    使用unix_timestamp()
    对于其他日期函数,请查看 here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 2014-02-03
      • 2013-04-01
      • 2011-07-10
      相关资源
      最近更新 更多