NOT IN , MATCHES 猪
Posted
技术标签:
【中文标题】NOT IN , MATCHES 猪【英文标题】:NOT IN , MATCHES in pig 【发布时间】:2017-02-09 08:18:55 【问题描述】:我在猪中有两个关系:
A,B
DUMP A;
桑迪普·罗汉·莫汉
DUMP B;
莫汉
我需要得到 A - B 的输出; 关系C应该给我
桑迪普,罗汉
因为它们不存在于 B
【问题讨论】:
【参考方案1】:试试这个:
A1 = LOAD 'Sandeep Rohan Mohan' USING PigStorage() AS (line:chararray);
B1 = LOAD 'MOHAN' USING PigStorage() AS (line:chararray);
A = FOREACH A1 GENERATE UPPER(line) AS line;
B = FOREACH B1 GENERATE UPPER(line) AS line;
C = COGROUP A BY line, B BY line;
D = FILTER C BY IsEmpty(B);
E = FOREACH D GENERATE group AS name;
DUMP E;
(罗汉)(桑迪普)
也可以参考sets operations in apache pig
【讨论】:
【参考方案2】:通过左外连接实现它,只考虑那些在 $1 中有空值的元组
【讨论】:
以上是关于NOT IN , MATCHES 猪的主要内容,如果未能解决你的问题,请参考以下文章