Kafka Connect cassandra source-十进制数据类型错误 [英] Kafka Connect cassandra source -error for Decimal data type

本文介绍了Kafka Connect cassandra source-十进制数据类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用kafka connect cassandra源连接器1.0版本.我在cassandra表中有一个十进制数据类型列(价格),并将其作为json从源连接器写入到kafka主题,它以某种字符串格式(如"price":"AA==")写入十进制值. 现在它在我的火花流中出错,同时转换为数字格式异常"浮动.... ??请提出在kafka主题中编写值时可能出了什么问题. 预先感谢.

I am using kafka connect cassandra source connector 1.0 version. I have a decimal datatype column(price) in cassandra table and writing it to the kafka topic as json from source connector,it is writing the decimal value in some string format like like "price":"AA==". Now it is giving error in my spark streaming while converting to float as "number format exception"....?? please suggest what may went wrong while writing the value in kafka topic. Advance thanks.

推荐答案

它看起来像已知错误.正如本期中所建议的那样,您需要将数据从base64编码的字符串执行手动"转换为BigDecimal:

It looks like the known bug in Kafka Connect + Decimals. As proposed in the issue, you'll need to perform "manual" conversion of data from base64-encoded string into BigDecimal:

BigDecimal bigDecimal = new BigDecimal(
    new  BigInteger(Base64.getDecoder().decode("BfXhAA==")), scale); 

这篇关于Kafka Connect cassandra source-十进制数据类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆