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

ExecuteSQL converts BigDecimal to strings in Avro

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 0.6.1
    • Fix Version/s: 1.3.0
    • Component/s: None
    • Labels:
      None

      Description

      Some JDBC drivers (Oracle is one of them) return NUMBER columns as BigDecimal. NiFi then turns that into a string in the Avro that is produced.

      This happens in JdbcCommon when creating the schema:

              
      case DECIMAL:
      case NUMERIC:            
      builder.name(meta.getColumnName(i)).type().unionOf()
        .nullBuilder().endNull().and().stringType().endUnion().noDefault();
      

      Then later when getting the value of the column to add to the Avro record:

      } else if (value instanceof BigDecimal || value instanceof BigInteger) {
                              rec.put(i - 1, value.toString());
                          } 
      

      It looks like Avro has support for Decimal types and we should look into using this:

      https://avro.apache.org/docs/1.7.7/spec.html#Logical+Types
      https://issues.apache.org/jira/browse/AVRO-1402

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                bbende Bryan Bende
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: