You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/03/11 23:15:00 UTC

[jira] [Commented] (KAFKA-5972) Flatten SMT does not work with null values

    [ https://issues.apache.org/jira/browse/KAFKA-5972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17057468#comment-17057468 ] 

ASF GitHub Bot commented on KAFKA-5972:
---------------------------------------

rhauch commented on pull request #4021: KAFKA-5972 Flatten SMT does not work with null values
URL: https://github.com/apache/kafka/pull/4021
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Flatten SMT does not work with null values
> ------------------------------------------
>
>                 Key: KAFKA-5972
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5972
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 0.11.0.0, 0.11.0.1
>            Reporter: Tomas Zuklys
>            Assignee: siva santhalingam
>            Priority: Minor
>              Labels: easyfix, patch
>             Fix For: 1.0.3, 1.1.2, 2.0.2, 2.1.2, 2.2.2, 2.4.0, 2.3.1
>
>         Attachments: kafka-transforms.patch
>
>
> Hi,
> I noticed a bug in Flatten SMT while doing tests with different SMTs that are provided out-of-box.
> Flatten SMT does not work as expected with schemaless JSON that has properties with null values. 
> Example json:
> {code}
>   {A={D=dValue, B=null, C=cValue}}
> {code}
> The issue is in if statement that checks for null value.
> Current version:
> {code}
>   for (Map.Entry<String, Object> entry : originalRecord.entrySet()) {
>             final String fieldName = fieldName(fieldNamePrefix, entry.getKey());
>             Object value = entry.getValue();
>             if (value == null) {
>                 newRecord.put(fieldName(fieldNamePrefix, entry.getKey()), null);
>                 return;
>             }
> ...
> {code}
> should be
> {code}
>   for (Map.Entry<String, Object> entry : originalRecord.entrySet()) {
>             final String fieldName = fieldName(fieldNamePrefix, entry.getKey());
>             Object value = entry.getValue();
>             if (value == null) {
>                 newRecord.put(fieldName(fieldNamePrefix, entry.getKey()), null);
>                 continue;
>             }
> {code}
> I have attached a patch containing the fix for this issue.



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