3

全部。我通过 jdbc 客户端使用 hive udf 时遇到了一个奇怪的错误。

我有一个 udf 可以帮助我将字符串转换为时间戳格式,称为reformat_date. 我首先执行ADD JARand CREATE TEMPORARY FUNCTION,两者都可以正常工作。

SQL 也可以在 hive cli 模式下解释,并且可以执行。但是当使用 jdbc 客户端时,我得到了错误:

    Query returned non-zero code: 10, cause: 
    FAILED: Error in semantic analysis: Line 1:283 Wrong arguments ''20121201000000'': 
    org.apache.hadoop.hive.ql.metadata.HiveException: 
    Unable to execute method public org.apache.hadoop.io.Text com.aa.datawarehouse.hive.udf.ReformatDate.evaluate(org.apache.hadoop.io.Text)  on object com.aa.datawarehouse.hive.udf.ReformatDate@4557e3e8 of class com.aa.datawarehouse.hive.udf.ReformatDate with arguments {20121201000000:org.apache.hadoop.io.Text} of size 1: 
    at com.aa.statistic.dal.impl.TjLoginDalImpl.selectAwakenedUserCount(TjLoginDalImpl.java:258)
    at com.aa.statistic.backtask.service.impl.UserBehaviorAnalysisServiceImpl.recordAwakenedUser(UserBehaviorAnalysisServiceImpl.java:326)
    at com.aa.statistic.backtask.controller.BackstatisticController$21.execute(BackstatisticController.java:773)
    at com.aa.statistic.backtask.controller.BackstatisticController$DailyExecutor.execute(BackstatisticController.java:823)

我的 SQL 是

select count(distinct a.user_id) as cnt from ( select user_id, user_kind, login_date, login_time from tj_login_hive where p_month = '2012_12' and login_date = '20121201' and user_kind = '0' ) a join ( select user_id from tj_login_hive where p_month <= '2012_12' and datediff(to_date(reformat_date(concat('20121201', '000000'))), to_date(reformat_date(concat(login_date, '000000')))) >= 90 ) b on a.user_id = b.user_id 

谢谢。

4

1 回答 1

0

我认为您的 udf 引发了异常。如果reformat_date功能是你做的,你应该检查你的逻辑。如果没有,您应该检查 udf 的规范。

于 2013-04-04T03:55:45.363 回答