前月の最後の日付を返すために月の日付を取得する必要があるユースケースがあります。
Ex: input:20150331 output:20150228
この前月の最後の日付を使用して、毎日のパーティションをフィルター処理します (豚のスクリプトで)。
B = filter A by daily_partition == GetPrevMonth(20150331);
日付を取得して前月の最後の日付を返す 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
}
助けが必要です。よろしくお願いします。