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

CSVRecordReader should utilize specified date/time/timestamp format at its convertSimpleIfPossible method

    XMLWordPrintableJSON

Details

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

    Description

      CSVRecordReader.convertSimpleIfPossible method is used by ValidateRecord. The method does not coerce values to the target schema field type if the raw string representation in the input CSV file is not compatible.

      The type compatibility check is implemented as follows. But it does not use user specified date/time/timestamp format:

                      // This will return 'false' for input '01/01/1900' when user specified custom format 'MM/dd/YYYY'
                      if (DataTypeUtils.isCompatibleDataType(trimmed, dataType)) {
                          // The LAZY_DATE_FORMAT should be used to check compatibility, too.
                          return DataTypeUtils.convertType(trimmed, dataType, LAZY_DATE_FORMAT, LAZY_TIME_FORMAT, LAZY_TIMESTAMP_FORMAT, fieldName);
                      } else {
                          return value;
                      }
      

      If input date strings have different format than the default format 'yyyy-MM-dd', then ValidateRecord processor can not validate input records.

      JacksonCSVRecordReader has the identical methods with CSVRecordReader. Those classes should have an abstract class.

      Attachments

        Issue Links

          Activity

            People

              derekstraka Derek Straka
              ijokarumawak Koji Kawamura
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: