Consider this script:

register udf-1.0.0-BETA.jar

A = LOAD '1.txt' USING PigStorage('\t') as (key1:chararray, val1:chararray);
B = LOAD '2.txt' USING PigStorage('\t') as (key2:chararray, val2:chararray);
joined = JOIN A by key1, B by key2;
out = FOREACH joined GENERATE com.example.UDF();
dump out;

Like so my UDF get only keys. If I try this:

out = FOREACH joined GENERATE com.example.UDF(joined);

I got an exception A column needs to be projected from a relation for it to be used as a scalar

I can pass entire relation like this

out = FOREACH joined GENERATE com.example.UDF(A::key1, A::val1, B::key2, B::val2);

But it's to verbose. Is there a simpler method?

有帮助吗?

解决方案

Yes, try the following:

out = FOREACH joined GENERATE com.example.UDF(*);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top