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

PutDatabaseRecord should use table column datatype instead of field datatype

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.13.0
    • Extensions
    • None

    Description

      When PutDatabaseRecord calls putObject() to insert a field value into a prepared statement, it passes is the SQL type as determined from the NiFi record field's type. Most of the time this matches the table column's data type or else an error would occur when trying to put incompatible values into the column.

      However in the case of the BIGINT and TIMESTAMP types, the field could be inferred to be BIGINT when the column is of type TIMESTAMP. There's no way to know for large integers whether they correspond to a "plain" number or a number of (milli)seconds for example. In this case PutDatabaseRecord throws an error because it tries to put a BIGINT value into a TIMESTAMP field.

      This Jira proposes to improve this by comparing the field and column datatypes. If they match, either can be used. If they don't match, attempt to convert the value to the column datatype and use the column datatype in setObject(). If conversion is unsuccessful, fall back to the current behavior of using the field datatype and value.

      Attachments

        Issue Links

          Activity

            People

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