Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using IN clause with PIG FILTER

Tags:

apache-pig

Does PIG support IN clause?

filtered = FILTER bba BY reason not in ('a','b','c','d');

or should i split it up into multiple OR's?

Thanks!

like image 934
hese Avatar asked Aug 24 '11 16:08

hese


3 Answers

You can use below udf from Apache DataFu instead. This will help you to avoid writing lot of OR.

https://github.com/linkedin/datafu/blob/master/src/java/datafu/pig/util/InUDF.java

like image 88
kris Avatar answered Sep 26 '22 01:09

kris


Pig 0.12 added In operator http://www.edureka.co/blog/operators-in-apache-pig-diagnostic-operators/ see bottom of page..release notes. Haven't located it in official docs (apart from bare mention in release notes)

like image 22
seanv507 Avatar answered Sep 26 '22 01:09

seanv507


I didn't find it in any of the samples in the documentation.

You can get by using AND/OR/NOT

like image 31
Icarus Avatar answered Sep 26 '22 01:09

Icarus