-Filtering based the value of an aggregate function?
Tim Chan 2013-07-29, 19:49
I would like to know if there is a better way to do the following.
I would like to filter out all records that are below the average score.
This is what I came up with:
data = load 'input.dat' using PigStorage('\t') as (name:chararray,
data_all = group data all;
avg_score = foreach data_all generate AVG(data.score) as avg_score;
data_avg = cross data, avg_score;
above_avg = filter data_avg by score > avg_score;
Is there a better or more acceptable way to make avg_score accessible
during the filter step, other than doing a cross?