我试图将H除以每行的AB。 H / AB在下面的线下方划分但产生了所有ZEROS。我真的很困惑。
sum_of_scores = FOREACH final_group GENERATE group AS id,
SUM(s.AB) AS AB,
SUM(s.H) AS H;
final_final = FOREACH sum_of_scores GENERATE $0 AS month_state, $1 AS AB, $2 AS H;
dump final_final
out_put = FOREACH final_final GENERATE month_state, (H / AB) AS score;
dump out_put
答案 0 :(得分:1)
似乎表达式(H / AB)
正在使用整数除法,因此参数应该首先使用cast operators转换为float
,例如。
答案 1 :(得分:0)
要扩展上述答案,应将每一列显式转换为浮点数:
out_put = FOREACH final_final GENERATE month_state, (FLOAT)((FLOAT)H/(FLOAT)AB) AS score;