Christian Danner created NIFI-8476:
--------------------------------------

             Summary: ConverRecord JSON to AVRO with logicalType date fails
                 Key: NIFI-8476
                 URL: https://issues.apache.org/jira/browse/NIFI-8476
             Project: Apache NiFi
          Issue Type: Bug
    Affects Versions: 1.13.2
            Reporter: Christian Danner
         Attachments: avro_date_test.xml

I setup an example Flow (Template) that transforms a JSON to AVRO Binary using 
the ConvertRecords while using JSONTreeReader and AVROSetWriter. Once I get 
JSON data as type INT and logicalType date passed to the processor, I get the 
result 0.
Idk what I am doing wrong, so I attached the Flow I used.

Generate Flowfile:

Custom Text:
{code:java}
{"DOCNUM":"0000000012345678","ERSDA":20210426,"LAEDA":18743}
{code}
avro.schema:
{code:java}
{
    "type": "record",
    "name": "MAT",
    "fields": [{
            "name": "DOCNUM",
            "size": 16,
            "type": [
                "null",
                "string"
            ],
            "default": null,
            "doc": "NA"
        }, {
            "name": "ERSDA",
            "size": 8,
            "type": [
                "null", {
                    "type": "int",
                    "logicalType": "date"
                }
            ],
            "default": null,
            "doc": "NA"
        }, {
            "name": "LAEDA",
            "size": 8,
            "type": [
                "null", {
                    "type": "int",
                    "logicalType": "date"
                }
            ],
            "default": null,
            "doc": "NA"
        }
    ]
}
{code}
Result:

Flowfile Viewer (formatted):
{code:java}
[ {
  "DOCNUM" : "0000000012345678",
  "ERSDA" : "1970-01-01",
  "LAEDA" : "1970-01-01"
} ]
{code}
avro-tools
{code:java}
avro-tools tojson ~/3a3c1a8e-5fda-4c67-a62c-bb9aacbcef1d
{"DOCNUM":{"string":"0000000012345678"},"ERSDA":{"int":0},"LAEDA":{"int":0}}
{code}



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

Reply via email to