You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Randall Hauch (Jira)" <ji...@apache.org> on 2020/05/07 22:43:00 UTC

[jira] [Updated] (KAFKA-9667) Connect JSON serde strip trailing zeros

     [ https://issues.apache.org/jira/browse/KAFKA-9667?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Randall Hauch updated KAFKA-9667:
---------------------------------
    Fix Version/s: 2.5.1
                   2.4.2
                   2.6.0

> Connect JSON serde strip trailing zeros
> ---------------------------------------
>
>                 Key: KAFKA-9667
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9667
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 2.4.0
>            Reporter: Andy Coates
>            Assignee: Andy Coates
>            Priority: Major
>             Fix For: 2.6.0, 2.4.2, 2.5.1
>
>
> The Connect Json serde was recently enhanced to support serializing decimals as standard JSON numbers, (Original work done under -KAFKA-8595)-, e.g. `1.23`.  However, there is a bug in the implementation: it's stripping trailing zeros!  `1.23` is _not_ the same as `1.230`.  The first is a number accurate to 2 decimal places, where as the later is accurate to 3 dp.
> It is important that trailing zeros are not dropped when de(serializing) decimals.  For some use-cases it may be acceptable to drop the trailing zeros, but for others it definitely is not.
> h3. Current Functionality
> If a JSON object was to contain the number `1.230` then the Java JsonDeserializer would correctly deserialize this into a `BigDecimal`. The BigDecimal would have a scale of 3, which is correct.
> However, if that same BigDecimal was then serialized back to JSON using the Java JsonSerializer it would incorrectly strip the zeros, serializing to `1.23`. 
> h3. Expected Functionality
> When serializing, trailing zeros should be maintained.  For example, a BigDecimal such as `1.230`, (3 dp), should be serialized as `1.230`. 
> h3. Compatibility
> With this bug fix any computation on decimal values that resulted in a number with trailing zeros, would see the number correctly serialized with those trailing zeros.
> Both the old serialized number, e.g. `1.23`, and the proposed corrected serialized number, e.g. `1.230`, are valid JSON numbers. Downstream consumers should have no issue deserializing either.  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)