confluentinc / confluentinc/kafka-tutorials
JDBC source connector --> Kafka Streams: handling Decimal types
- Dominant language
- Java
- Stars
- 39
- Forks
- 91
- PR merge metrics
- No merged PRs in 30d
Description
An JDBC Source Connector publishes data to a kafka topic. In Kafka Streams, using `GenericAvroSerde`, for all the numeric fields, the streams application is printing bytes and not the decimal.
Sample code to address this:
```
LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) value.getSchema().getField("NUMBER_VALUE").schema().getLogicalType();
ByteBuffer number = (ByteBuffer) value.get("NUMBER_VALUE");
byte[] numberArray = Utils.toArray(number);
BigDecimal decimal_number = new BigDecimal(new BigInteger(numberArray), decimal.getScale());
```
reference: [Slack convo](https://confluentcommunity.slack.com/archives/C48AHTCUQ/p1566381843422700?thread_ts=1525962908.000612&cid=C48AHTCUQ)
Contributor guide
Assessment
This issue has not been assessed yet.