You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/11/16 16:41:00 UTC

[jira] [Commented] (NIFI-7996) Conversion with ConvertRecord to avro results in invalid date

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

ASF subversion and git services commented on NIFI-7996:
-------------------------------------------------------

Commit 83948db989bf2f682dfa18c56293ec431f546e1c in nifi's branch refs/heads/main from Denes Arvay
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=83948db ]

NIFI-7996 Conversion with ConvertRecord to avro results in invalid date

Signed-off-by: Pierre Villard <pi...@gmail.com>

This closes #4666.


> Conversion with ConvertRecord to avro results in invalid date
> -------------------------------------------------------------
>
>                 Key: NIFI-7996
>                 URL: https://issues.apache.org/jira/browse/NIFI-7996
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Denes Arvay
>            Assignee: Denes Arvay
>            Priority: Critical
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Converting a date field to avro using ConvertRecord results to invalid value if the system's timezone's offset is negative.
> System timezone: EST (UTC-5)
> Input json:
> {code:java}
> { "SomeLocalDate": "20170411" }
> {code}
> Avro schema:
> {code:java}
> { "fields": [ {
>        "name": "SomeLocalDate",
>        "type": [ "null", { "logicalType": "date", "type": "int" } ]
>   }],
>  "name": "DateTest",
>  "namespace": "org.apache.nifi",
>  "type": "record"
> }
> {code}
> Result:
> {code:java}
> $ avro-tools tojson ./est-invalid.avro
> {"SomeLocalDate":{"int":17266}}
> {code}
> In this case the days between 1970.01.01. and 2017.04.11. is stored in the SomeLocalDate field (see [1]), it should be 17267 ([2]).
> After investigating the issue it seems that even though {{20170411}} is parsed to {{2017-04-11T00:00:00 UTC}} it is converted to the system timezone ({{2017-04-10T19:00:00 EST}}) later and its date value is used.
> [1] [https://avro.apache.org/docs/1.8.0/spec.html#Date]
>  [2] [https://www.timeanddate.com/date/durationresult.html?d1=1&m1=1&y1=1970&d2=11&m2=04&y2=2017]
>   



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