2017-11-06 21 views
0

私は最後のコマンドを実行している間、私はこのエラーを持っている以外の豚合計:エラー1045

A = LOAD 's3://input' AS (filed1:chararray, filed2:int, field3:float, field4:float); 
filtered_1 = FILTER A BY field3 >= 10; 
filtered_2 = FILTER filtered_1 BY field4 >= 50; 
grouped = GROUP filtered_2 BY field1; 
B = FOREACH grouped GENERATE group as field1, SUM(A.field3)/SUM(A.field4) AS A_avg; 

を使用して2つの和の割り算を計算したい:

ERROR grunt.Grunt: ERROR 1045: <line 5, column 55> Could not infer the matching function for org.apache.pig.builtin.SUM as multiple or none of them fit. Please use an explicit cast. 

そして、私は、なぜ見つけることができません私がSUMを実行する前にGROUPを使用していて、私はSUMの文書を読んできました。私が書いたものと何が違うのか分かりません。

答えて

1
grouped = GROUP filtered_2 BY field1; 

grouped has no ACCESS to alias A . 

B = FOREACH grouped GENERATE group as field1, SUM(A.field3)/SUM(A.field4) AS A_avg; 

"FOREACH grouped " has no access to alias A but directly to fields (field3, field4) 






filtered_1 = FILTER A BY field3 >= 10; 
filtered_2 = FILTER filtered_1 BY field4 >= 50; 


All you are doing in this statement is an AND operation 

filtered_3 = FILTER A BY field3 >= 10 AND field4 >= 50; 

Now 
grouped = GROUP filtered_3 BY field1; 
B = FOREACH grouped GENERATE group as field1, SUM(filtered_3.field3)/SUM(filtered_3.field4) AS A_avg;