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