PIG 减去两个日期
PIG subtract two dates
我正在尝试用 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)
我想在 deactivation_date 和 activation_date 之间设置日期差异,结果收到 'key_one' 和 'days between two dates'。
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 运算符密钥:scope-231)时发生异常:子项:[]] 处为空:java.lang.NullPointerException
有什么想法,如何解决这个问题?
deactivation_date
和 activation_date
是 DateTime 类型吗?
如果没有,以下内容应该有所帮助:
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;
我正在尝试用 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)
我想在 deactivation_date 和 activation_date 之间设置日期差异,结果收到 'key_one' 和 'days between two dates'。
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 运算符密钥:scope-231)时发生异常:子项:[]] 处为空:java.lang.NullPointerException
有什么想法,如何解决这个问题?
deactivation_date
和 activation_date
是 DateTime 类型吗?
如果没有,以下内容应该有所帮助:
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;