Pig减去两个日期

mbskvtky  于 2021-06-25  发布在  Pig
关注(0)|答案(1)|浏览(394)

我想减去和Pig的两次约会。
我有这样的数据: key_one, activation_date , deactivation_date (1456,2010-06-14 00:00:00,2011-01-01 00:00:00) (6524,2015-01-15 00:00:00,2015-02-07 00:00:00) (1541,2010-07-17 00:00:00,2012-03-07 00:00:00) 我想在停用日期和激活日期之间做一个日期差,结果收到“密钥一”和“两个日期之间的天数”。

DATA_OUTPUT  = foreach MY_DATA generate key_one,
              DaysBetween(deactivation_date, activation_date) as days_between_two_dates;

后端错误:执行[pouserfunc(名称:pouserfunc(org.apache.pig.builtin.daysbetween)[long]-scope-231 operator key:scope-231)子项时发生异常:[]]:java.lang.nullpointerexception
有什么想法,怎么解决这个问题?

omhiaaxx

omhiaaxx1#

deactivation_date 以及 activation_date 日期时间类型?
如果没有,以下几点应该会有所帮助:

DATA_OUTPUT  = foreach MY_DATA generate key_one,
          DaysBetween(ToDate(deactivation_date, 'yyyy-MM-dd HH:mm:ss'), ToDate(activation_date, 'yyyy-MM-dd HH:mm:ss')) as days_between_two_dates;

相关问题