Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7996

Conversion with ConvertRecord to avro results in invalid date

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • None
    • 1.13.0
    • None
    • None

    Description

      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:

      { "SomeLocalDate": "20170411" }
      

      Avro schema:

      { "fields": [ {
             "name": "SomeLocalDate",
             "type": [ "null", { "logicalType": "date", "type": "int" } ]
        }],
       "name": "DateTest",
       "namespace": "org.apache.nifi",
       "type": "record"
      }
      

      Result:

      $ avro-tools tojson ./est-invalid.avro
      {"SomeLocalDate":{"int":17266}}
      

      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
       

      Attachments

        Issue Links

          Activity

            People

              denes Denes Arvay
              denes Denes Arvay
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m