0
這是一個基本的PIG問題。 我有我的數據是這樣的PIG集團避免袋
10 | Dog
15 | Cow
20 | Dog
15 | Elephant
15 | Dog
25 | Elephant
我想要找的平均重量每隻動物的,並具有輸出,因爲這:
Dog | 12.5
Elephant | 20
Cow | 15
我能夠通過使用GROUP和得到的結果,但結果是一個袋子,像這樣:
{(Dog), (Dog) } | 12.5
{(Elephant), (Elephant)} | 20
{(Cow)} | 15
我怎樣才能提取個別動物?
我正在使用這樣的GROUP。
--animal_weight is derived through other means
animal_by = GROUP animal_weight by (animal);
results = FOREACH animal_by GENERATE animal_weight.animal as animal_name, AVG(animal_weight.weight) as kg;
STORE results INTO '$output_4' USING PigStorage('|');
謝謝!我剛剛想出了12.5,應該做的數學:-) – EnnioMorricone