Pig Round Decimal to Two Places

风格不统一 提交于 2019-12-12 03:01:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!