Reputation: 21
a = load '/user/home/samp.txt' using PigStorage(',');
dump a;
(2008-Jan-12,12.1,13.1,36.0)
(2008-Jan-13,13.1,14.1,45.00)
(2008-Jan-15,14.2,15.2,47.00)
(2008-Jan-16,16.1,17.1,47.5)
(2008-Jan-12,8.5,17,50,12.0)
(2008-Jan-12,n#/a,n#/a,n#/a)
(2008-Jan-19,n#/a,n#/a,n#/a)
(2008-Jan-12,n#/a,n#/a,27)
(2008-Jan-12,n#/a,13.00,n#/a)
b = filter a by ($1!='n#/a' OR $2!='n#/a' OR $3!='n#/a');
dump b;
(2008-Jan-12,12.1,13.1,36.0)
(2008-Jan-13,13.1,14.1,45.00)
(2008-Jan-15,14.2,15.2,47.00)
(2008-Jan-16,16.1,17.1,47.5)
(2008-Jan-12,8.5,17,50,12.0)
(2008-Jan-12,n#/a,n#/a,27)
(2008-Jan-12,n#/a,13.00,n#/a)
why still iam getting "n#/a"
in b
Upvotes: 1
Views: 3687
Reputation: 11080
The result is as expected because you are using != and OR.You are getting rows with "n#/a"
because atleast one of the condition is true for (2008-Jan-12,n#/a,n#/a,27)
and (2008-Jan-12,n#/a,13.00,n#/a)
If you want to filter the rows with no "n#/a"
use AND
.
B = FILTER A BY (($1 != 'n#/a') AND ($2 != 'n#/a' ) AND ($3 != 'n#/a' ));
If you want to use OR then combine the logical OR resutls and then negate
B = FILTER A BY NOT($1 == 'n#/a' OR $2 == 'n#/a' OR $3 == 'n#/a');
OR
B = FILTER A BY NOT($1 matches 'n#/a' OR $2 matches 'n#/a' OR $3 matches 'n#/a');
Output
Upvotes: 2