バッグのタプルを UDF に渡したいと思います。
すべての要素がarg
2 つのバッグ (x
とy
)のタプル ( ) であるこのデータ構造があります。
data:{arg: (x: {(a: int,b: int,)},y: {(a: int,b: int)})}
次に、UDF を作成しました。
public class MyUDF extends EvalFunc<String> {
public String exec(Tuple input) throws IOException {
if(input == null || input.size() == 0)
return "empty";
try{
DataBag ref_regions = (DataBag)input.get(0);
return "OK";
}catch(Exception e){
System.err.println(e.getMessage());
return null;
}
}
}
そして、次のように PigLatin スクリプト内で呼び出します。
res = foreach data generate MyUDF(arg);
残念ながら、次のエラーが発生しました。
org.apache.pig.data.BinSedesTuple cannot be cast to org.apache.pig.data.DataBag
catch
これは、ステートメントによって印刷されます。
それを直すのを手伝ってくれませんか?