猪圆十进制到两个地方

时间:2013-03-21 02:40:08

标签: apache-pig

关于如何在Apache Pig中将Float数据类型舍入到2位小数的任何想法?

例如:

  test = FOREACH (JOIN Load by (Op1, Op2), Load2 by (Op3,Op4)) GENERATE 
  Load2::Number2 *Load::Number1 as Output

字段Number1和Number2是浮点数。我当前的计算给出了5到6个小数位。

1 个答案:

答案 0 :(得分:0)

试试这个:

 B = FOREACH A GENERATE (((A.myfloat1 * A.myfloat2)*100f)ROUND)/100f AS myfloat3