Piotr Smolinski created KAFKA-9067:
--------------------------------------
Summary: BigDecimal conversion unnecessarily enforces the scale
Key: KAFKA-9067
URL: https://issues.apache.org/jira/browse/KAFKA-9067
Project: Kafka
Issue Type: Bug
Components: KafkaConnect
Affects Versions: 2.3.0
Reporter: Piotr Smolinski
In Kafka Connect schema framework it is possible to use fixed point decimal
numbers mapped as logical type Decimal. The type is related to Avro defined
logical type. When the type is used, the scale value is stored in the schema
definition (later it might end in Avro schema) and the unscaled value is stored
as integer of unbounded size.
The problem arises when the decimal value to decode has different scale than
the one declared in the schema. During conversion to Avro or JSON using
standard converters the operation fails with DataException.
The proposed solution is to use setScale method to adapt the scale to the
correct value and provide rounding mode as parameter to the schema:
https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html#setScale-int-java.math.RoundingMode-
--
This message was sent by Atlassian Jira
(v8.3.4#803005)