Change Decimal Precision of all 'Double type' Columns in a Spark Dataframe

最后都变了- 提交于 2021-02-08 07:24:35

问题


I have a Spark DataFrame, let's say 'df'.

I do the following simple aggregation on this DataFrame:

df.groupBy().sum()

Upon doing so, I get the following exception:

java.lang.IllegalArgumentException: requirement failed: Decimal precision 39 exceeds max precision 38

Is there any way I can fix this?

My guess is, if I can decrease the decimal precision of all the columns of double type in df, it would solve the problem.

来源:https://stackoverflow.com/questions/46462377/change-decimal-precision-of-all-double-type-columns-in-a-spark-dataframe

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