HarishKotha
HarishKotha

Reputation: 78

Left outer join on more than 2 relations at a time in PIG

I am trying to perform a left outer join for more that 2 relations in a single statement in pig. Is it possible?

Regards Harish

Upvotes: 1

Views: 256

Answers (1)

Balduz
Balduz

Reputation: 3570

Unfortunately, multi-way joins in one step only work for inner joins. Taken from the official documentation:

Usage

...

Outer joins will only work for two-way joins; to perform a multi-way outer join, you will need to perform multiple two-way outer join statements.

So until they add the possibility, which won't be anytime soon (there are no open JIRAs working on it), you will need to do it in 2 statements:

A = LOAD 'a' AS (a:chararray,b:int);
B = LOAD 'b' AS (a:chararray,b:chararray);
C = LOAD 'c' AS (a:chararray,b:chararray);
D = JOIN A by $0 LEFT OUTER, B BY $0;
E = JOIN D by $0 LEFT OUTER; C BY $0;

Upvotes: 3

Related Questions