问题
Any ideas on how I Can Round a Float data type to 2 decimal places in Apache Pig?
For example:
test = FOREACH (JOIN Load by (Op1, Op2), Load2 by (Op3,Op4)) GENERATE
Load2::Number2 *Load::Number1 as Output
The fields Number1 and Number2 are floats.My current calculations give me 5 to 6 decimal places.
回答1:
Try this:
B = FOREACH A GENERATE (((A.myfloat1 * A.myfloat2)*100f)ROUND)/100f AS myfloat3
来源:https://stackoverflow.com/questions/15538504/pig-round-decimal-to-two-places