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

PutSQL doesn't handle nanoseconds

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.12.0, 1.11.4
    • Extensions
    • None

    Description

      According to the documentation PutSQL should be able to manage nanoseconds:

      https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.0/org.apache.nifi.processors.standard.PutSQL/

      ".]sql.args.N.format [...] as specified according to java.time.format.DateTimeFormatter"

      DateTimeFormatter should be able to manage nanoseconds.

      The issue seems to be happening in JdbcCommon.java

      Line 840-843:
      final DateTimeFormatter dtFormatter = getDateTimeFormatter(valueFormat);
      TemporalAccessor accessor = dtFormatter.parse(parameterValue);
      java.util.Date parsedDate = java.util.Date.from(Instant.from(accessor));
      lTimestamp = parsedDate.getTime();

      It seems to be truncated on line 842
      java.util.Date parsedDate = java.util.Date.from(Instant.from(accessor));

      as java.util.Date doesn't handle nanoseconds. A Java time construct that can handle nanoseconds should be used instead of Date.

      Attachments

        Activity

          People

            mattyb149 Matt Burgess
            mattyb149 Matt Burgess
            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 - 1h
                1h