[Solved-1 Solution] Find average by joining two datasets in pig ?
What is average()
- The Pig-Latin AVG() function is used to compute the average of the numerical values within a bag. While calculating the average value, the AVG() function ignores the NULL values.
- Given below is the syntax of the AVG() function.
- We can find average by using average function which is available in apache pig.
What is foreach ?
- The FOREACH operator is used to generate specified data transformations based on the column data.
How to find average by joining two datasets in pig ?
We can also solve using foreach statement
- Group command will not work inside nested Foreach, its restricted in pig. Only few commands are allowed inside the nested foreach (CROSS, DISTINCT, FILTER, FOREACH, LIMIT, and ORDER BY).
Output for the above program: