1

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

Balázs Édes
  • 13,452
  • 6
  • 54
  • 89
Altober
  • 956
  • 2
  • 14
  • 28

1 Answers1

2

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.

LiMuBei
  • 2,868
  • 22
  • 27