Pig pass relation as argument to UDF

这一生的挚爱 提交于 2019-12-24 13:26:33

问题


I need to pass a relation to a UDF in PIG

 articles = load x using ...;
 groupedArticles = udfs.MyUDF(articles);

Is something like this possible? Any workaround?

thanks


回答1:


I guess you mean to pass all fields of the relation to the UDF? Passing the relation would not make sense. In any case this depends on how your load statement looks like. If you load each entry as a tuple load x using ... as (entry:(a:int, b:chararray, ...)) than you could pass that to the UDF like groupedArticles = foreach articles generate udfs.MyUDF(entry) Passing the whole line as a tuple is probably the most generic way, you have to deal with a generic tuple in your UDF though.



来源:https://stackoverflow.com/questions/28023561/pig-pass-relation-as-argument-to-udf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!