This sounds like a bug. I'll check it out tomorrow. On Sat, Feb 19, 2011 at 7:04 PM, sonia gehlot <sonia.geh...@gmail.com>wrote:
> Here is an example, Hope this will help. I am running this on Pig 0.8 > version. > > Sample data in text file > sample1.txt > > John USA www.google.com 1234 900 > Ron California www.facebook.com 1432 400 > Sam NY www.orkut.com 5432 400 > Bill UK www.google.com 5647 645 > > > abc = LOAD '/user/sgehlot/test_data/sample1.txt' as (name: chararray, > country: chararray, website: chararray, sess_id: int, page_id: int); > > case_abc = FOREACH abc GENERATE > name, > country, > ((website matches '.*.google..*') ? sess_id : null ) as google_user, > ((page_id == 400) ? sess_id : null) as other_user; > > DUMP case_abc; > ------------------ > result of DUMP case_abc; > > (John,USA,1234,) > (Ron,California,,1432) > (Sam,NY,,5432) > (Bill,UK,5647,) > > ----------------- > gen_case = FOREACH case_abc GENERATE name, country, google_user, > other_user; > > DUMP gen_case; > --------------- > result of DUMP gen_case; > > (John,USA,1234,1234) > (Ron,California,,) > (Sam,NY,,) > (Bill,UK,5647,5647) > > You can see in 1st DUMP if conditions are working fine. Then in 2nd dump > after 2nd foreach it messed up with if conditions. > > Let me know if it does make any sense. > > Sonia > > > On Sat, Feb 19, 2011 at 4:55 PM, Dmitriy Ryaboy <dvrya...@gmail.com>wrote: > >> Hi Sonia, >> Looks like something went wrong in your pasting of the Pig code. Could you >> try again, and also add some sample inputs/outputs? >> >> As in, contents of join_pe_pre, contents of case_state, and contents of >> gen_values that illustrate the problem and allow us to reproduce it. >> >> Also please tell us what version of Pig you are using. >> >> Thanks, >> -D >> >> On Sat, Feb 19, 2011 at 3:39 PM, sonia gehlot <sonia.geh...@gmail.com>wrote: >> >>> Hi Guys, >>> >>> I getting wired error while running my pig script. >>> >>> *case_state = FOREACH join_pe_pre GENERATE* >>> >>> * f1, f2, f3, f4, (* >>> >>> * (f5 '.*.facebook..*')* >>> >>> * ? f10* >>> >>> * : null* >>> >>> * ) as facebook_referrals,* >>> >>> * >>> * >>> >>> * (* >>> >>> * (* >>> >>> * (f6 == 1)* >>> >>> * AND* >>> >>> * (f7 == 2000)* >>> >>> * AND* >>> >>> * (f8 == 1)* >>> >>> * )* >>> >>> * ? f10* >>> >>> * : null* >>> >>> * ) as cd_referrals,* >>> >>> * >>> * >>> >>> * (* >>> >>> * (* >>> >>> * (f7 == 1770)* >>> >>> * OR* >>> >>> * (f7 == 1771)* >>> >>> * )* >>> >>> * ? f10* >>> >>> * : null* >>> >>> * ) as nm_referrals;* >>> >>> * >>> * >>> >>> *DUMP case_state;* >>> >>> >>> Here when I am doing DUMP case_state I am getting desired results, proper >>> case values for facebook_referrals, cd_referrals and nm_referrals >>> >>> >>> *gen_values = FOREACH case_state GENERATE *;* >>> >>> * >>> * >>> *DUMP gen_values; * >>> * >>> * >>> But after this if I do simple FOREACH GENERATE everything again at this >>> moment I am getting same values for facebook_referrals, cd_referrals >>> and nm_referrals. All these three values are same as whatever the value >>> of >>> first if else. >>> I could able to figure out what could be the possible reason of this. >>> >>> Please let me know if I am doing anything wrong. >>> >>> Thanks in advance. >>> >>> Sonia >>> >> >> >