Reputation: 502
I am trying to divide H by AB for each line. H / AB in the below line way below divies but produces an out of all ZEROS. I am really confused.
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
Upvotes: 1
Views: 658
Reputation: 1
To expand upon the answer above, each column should explicitly be cast to a float:
out_put = FOREACH final_final GENERATE month_state, (FLOAT)((FLOAT)H/(FLOAT)AB) AS score;
Upvotes: 0
Reputation: 453
It appears as though the expression (H / AB)
is using integer division, so the arguments should first make use of the cast operators to convert to float
, for example.
Upvotes: 2