根据条件在 apache pig 中加入两个别名

join two aliases in apache pig based on a condition

我想加入两个 aliases/relations,

say A has keys : a,b,c
and B has keys : x,y,z

所以应该是:

C = JOIN A by a, (IF B.x matches "foo.*" then pick y else z)

如上logic.How我可以这样做吗?

我的回答:

只需根据条件生成一个键,然后通过该键加入

例如

BB = foreach B generate x,y,z,(x matches "foo.*") ? y : z as matchkey;
C = join A by a, BB by matchkey;
dump c;