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

ValidateRecord routes JSON records to 'invalid' when validating a timestamp, even if format is valid

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.10.0
    • Extensions
    • None

    Description

      If a JSON Reader (either JsonPath or JsonTree reader) is used with ValidateRecord and the schema indicates that a field is a timestamp (e.g.,

      {"name": "timestamp", "type": {"type": "long", "logicalType":"timestamp-millis"}}

      ) with the JSON having a value like "2019/06/10 12:00:00Z" and a format of "yyyy/MM/dd HH:mm:ss'Z'" The processor considers this invalid, even when setting "strict type checking" to "false".

      This appears to be due to the way that ValidateRecord calls RecordReader.nextReader() - it calls it "reader.nextRecord( /* coerce types */ false, /* drop unknown types */ false)" 

      When this is called, the Record Reader checks the 'coerce types' flag and determines that it should not coerce the string "2019/06/10 12:00:00Z" into a timestamp. However, for any date/time/timestamp fields, if the value is a String and it matches the configured pattern, the Record Readers should go ahead and convert the value into the appropriate java.sql.Date, java.sql.Time, java.sql.Timestamp object because that's clearly the intent of the schema and formatting being applied.

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              markap14 Mark Payne
              Votes:
              0 Vote for this issue
              Watchers:
              3 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