Skip to content

JDBC source connector --> Kafka Streams: handling Decimal types #127

Open
@ybyzek

Description

@ybyzek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    connectRelates to Kafka Connect and connectors sourcing data from or sinking data to other end systemskstreamsKafka Streams Relatedrecipe

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions