Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. REGISTER /usr/hdp/current/pig-client/piggybank.jar;
  2.  
  3.  
  4. lifes = LOAD 'labs/hadoop/pig/Life_Expectancy_Data.csv' USING org.apache.pig.piggybank.storage.CSVExcelStorage() as (
  5. country:chararray,
  6. year:int,
  7. status:chararray,
  8. life_expectancy:double,
  9. adult_mortality:int,
  10. infant_deaths:int,
  11. alcohol:double,
  12. percentage_expenditure:double,
  13. hepatitis_b:int,
  14. measles:int,
  15. BMI:double,
  16. under_five_deaths:int,
  17. polio:int,
  18. total_expenditure:double,
  19. diphtheria:int,
  20. HIV_AIDS:double,
  21. GDP:double,
  22. Population:int,
  23. thinness_1_19_years:double,
  24. thinness_5_9_years:double,
  25. income_composition_of_resources:double,
  26. schooling:double);
  27.  
  28.  
  29. grouped = GROUP lifes BY country;
  30. resultsAvg = FOREACH grouped GENERATE lifes.country, AVG(lifes.Population) as averagePop, AVG(lifes.life_expectancy) as averageLife ;
  31. results = ORDER resultsAvg BY averagePop DESC;
  32. results = LIMIT results 3;
  33.  
  34. DUMP results;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement