hadoop - PIG Filter by latest year -


how filter data takes updated information? here's sample data.

data:

united states of america    2000    dentistry personnel density 162.7 united states of america    2000    health management & support workers 1237.9 united states of america    2000    laboratory health workers   228.4 united states of america    1995    nursing , midwifery personnel 879.80005 united states of america    2000    nursing , midwifery personnel 936.69995 united states of america    2005    nursing , midwifery personnel 981.49994 united states of america    1995    other health workers    650.89996 united states of america    2000    other health workers    1452.1 united states of america    2005    other health workers    494.3 united states of america    2009    other health workers    849.89996 united states of america    2010    other health workers    857.9 united states of america    2011    other health workers    845.89996 united states of america    2000    pharmaceutical personnel    87.6 united states of america    2010    pharmaceutical personnel    88.1 united states of america    1995    physicians  239.5 united states of america    2000    physicians  256.4 united states of america    2004    physicians  267.19998 united states of america    2005    physicians  240.9 united states of america    2006    physicians  240.2 united states of america    2007    physicians  241.00002 united states of america    2008    physicians  241.59999 united states of america    2009    physicians  242.2 united states of america    2010    physicians  241.00002 united states of america    2011    physicians  245.2 uruguay 2002    dentistry personnel density 116.1 uruguay 2008    dentistry personnel density 70.1 uruguay 2008    health management & support workers 69.5 uruguay 2008    laboratory health workers   17.0 uruguay 2002    nursing , midwifery personnel 84.899994 uruguay 2008    nursing , midwifery personnel 554.8 uruguay 2008    other health workers    137.0 uruguay 2008    pharmaceutical personnel    53.100002 uruguay 2002    physicians  365.19998 uruguay 2008    physicians  373.6 

what want:

united states of america    2000    dentistry personnel density 162.7 united states of america    2000    health management & support workers 1237.9 united states of america    2000    laboratory health workers   228.4 united states of america    2005    nursing , midwifery personnel 981.49994 united states of america    2011    other health workers    845.89996 united states of america    2010    pharmaceutical personnel    88.1 united states of america    2011    physicians  245.2 uruguay 2008    dentistry personnel density 70.1 uruguay 2008    health management & support workers 69.5 uruguay 2008    laboratory health workers   17.0 uruguay 2008    nursing , midwifery personnel 554.8 uruguay 2008    other health workers    137.0 uruguay 2008    pharmaceutical personnel    53.100002 uruguay 2008    physicians  373.6 

i want make sure if country , career same, filter latest year given.

here's code, it's not working.

b = load '/nomnom' (country:chararray, year:int, career:chararray, density:chararray);  c = group b (country,career);  d = foreach c generate max(b.year) val, group, $1 max;  e = foreach d { row = filter b (year == val); generate flatten(row); };  dump e; 

after grouped (c), sort grouped data year , take latest one:

d = foreach c {   sorted = order b year desc;   latest = limit sorted 1;   generate flatten(latest); } dump d; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -