Kafka Connect cassandra source -error for Decimal data type

白昼怎懂夜的黑 提交于 2019-12-11 17:47:10

问题


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.


回答1:


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); 


来源:https://stackoverflow.com/questions/53390352/kafka-connect-cassandra-source-error-for-decimal-data-type

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