Pergunta

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?

Foi útil?

Solução

Yes, try the following:

out = FOREACH joined GENERATE com.example.UDF(*);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top