我是靠谱客的博主 谦让砖头,最近开发中收集的这篇文章主要介绍ClickHouse exception, message: Code: 407. DB::Exception: Decimal math overflow 十进制溢出错误,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
记一次ClickHouse使用中遇到的问题
报错:
org.springframework.jdbc.UncategorizedSQLException:
### Error querying database.
Cause: ru.yandex.clickhouse.except.ClickHouseUnknownException: ClickHouse exception, message: Code: 407. DB::Exception: Decimal mathoverflow: while executing 'FUNCTION multiply(toDecimal32OrZero(xxx, 0) :: 7, 100 :: 3) -> multiply(toDecimal32OrZero(xxx, 0), 100) Decimal(9, 0): 5'. (DECIMAL_OVERFLOW) (version
(official build))
### The error may exist in class path resource [mapper/ClickHouse/com/rs/smp/speedResult/SpeedResultDescCkMapper.xml]
### The error may involve com.rs.smp.speedResult.dao.clickHouse.SpeedResultDescCkDao.queryUpload-Inline
### The error occurred while setting parameters
### SQL: SELECT count(0) FROM tbl_day_speed_aaa_list WHERE intDivOrZero(toDecimal32OrZero(xxx, 0) * 100, toDecimal32OrZero(replace(broadwidth, 'M', ''), 0)) >= 90
### Cause: ru.yandex.clickhouse.except.ClickHouseUnknownException: ClickHouse exception, message: Code: 407. DB::Exception: Decimal math overflow: while executing'FUNCTION multiply(toDecimal32OrZero(xxx, 0) :: 7, 100 :: 3) -> multiply(toDecimal32OrZero(xxx, 0), 100) Decimal(9, 0) : 5'. (DECIMAL_OVERFLOW) (version
(official build))
; uncategorized SQLException; SQL state [null]; error code [1002]; ClickHouse exception, message: Code: 407. DB::Exception: Decimal math overflow: while executing'FUNCTION multiply(toDecimal32OrZero(xxx, 0) :: 7, 100 :: 3) -> multiply(toDecimal32OrZero(xxx, 0), 100) Decimal(9, 0) : 5'. (DECIMAL_OVERFLOW) (version
(official build)); nested exception is ru.yandex.clickhouse.except.ClickHouseUnknownException: ClickHouse exception, message: Code: 407. DB::Exception: Decimal math overflow: while executing 'FUNCTION multiply(toDecimal32OrZero(xxx, 0) :: 7, 100 :: 3) -> multiply(toDecimal32OrZero(xxx, 0), 100) Decimal(9, 0) : 5'. (DECIMAL_OVERF
问题原因:
clickhoue表中数据类型为String,正常数据为10000以内的数字,但存在异常数据例如将手机号错入进了该字段。导致toDecimal32OrZero(xxx, 0)函数将String转为数字进行计算时出现了十进制溢出错误。
解决方式:
toDecimal32OrZero函数 替换为 toDecimal64OrZero函数
记俩篇常用ClickHouse函数的博客:
ClickHouse 函数极简教程:https://blog.csdn.net/universsky2015/article/details/123587836
clickhouse 数据类型转换:https://blog.csdn.net/weixin_38424594/article/details/123545926
最后
以上就是谦让砖头为你收集整理的ClickHouse exception, message: Code: 407. DB::Exception: Decimal math overflow 十进制溢出错误的全部内容,希望文章能够帮你解决ClickHouse exception, message: Code: 407. DB::Exception: Decimal math overflow 十进制溢出错误所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复