0
我有一个用例,我需要在一个月的日期返回上个月的最后一个日期。过滤器上的猪udf
Ex: input:20150331 output:20150228
我将使用此前一个月的最后日期来过滤每日分区(在猪脚本中)。
B = filter A by daily_partition == GetPrevMonth(20150331);
我创建了需要的日期,并返回前一个月的最后date.But无法使用它在过滤器上的UDF(GetPrevMonth)。
ERROR:Could not infer the matching function for GetPrevMonth as multiple or none of them fit. Please use an explicit cast.
我的udf以元组为输入。 谷歌搜索说,UDF不能应用于过滤器。 有什么解决方法吗?或者我在哪里错了?
UDF:public class GetPrevMonth extends EvalFunc<Integer> {
public Integer exec(Tuple input) throws IOException {
String getdate = (String) input.get(0);
if (getdate != null){
try{
//LOGIC to return prev month date
}
需要帮助。提前致谢。
你应该接受Balduz的答案,除非你觉得这是不能令人满意的(对我来说,似乎右) – Eyal