Peter Gyori created NIFI-9192:
---------------------------------

             Summary: Value of QueryDatabaseTableRecord's "Use Avro Logical 
Types" property ignored when determining the schema of the recordset
                 Key: NIFI-9192
                 URL: https://issues.apache.org/jira/browse/NIFI-9192
             Project: Apache NiFi
          Issue Type: Bug
          Components: Extensions
            Reporter: Peter Gyori
            Assignee: Peter Gyori


In RecordSqlWriter, the avro schema is determined using this:
{code:java}
final Schema avroSchema = JdbcCommon.createSchema(resultSet, options);{code}
Here, in 'options' the value of "Use Avro Logical Types" is passed and taken 
into consideration. This avroSchema is used to create the recordAvroSchema, 
which is OK:
{code:java}
final RecordSchema recordAvroSchema = 
AvroTypeUtil.createSchema(avroSchema);{code}
*However*, when creating the fullRecordSet object (which contains the schema as 
well, the creation:
{code:java}
fullRecordSet = new ResultSetRecordSetWithCallback(resultSet, recordAvroSchema, 
callback, options.getDefaultPrecision(), options.getDefaultScale()){code}
does not consider the value of the useLogicalTypes flag since it is not passed 
to the constructor. recordAvroSchema was created considering the value of the 
flag, and is passed to the constructor but *the settings in this schema are 
overridden during the ResultSetRecordSet creation*, where a schema is created 
based on the metadata received from the database.

As a result, if we have "Use Avro Logical Types" set to false, and we have a 
column in an Oracle DB table (for the sake of this example) that is of type 
NUMBER, the resulting avro shcema is:
{code:java}
    "type" : {
      "type" : "bytes",
      "logicalType" : "decimal",
      "precision" : 10,
      "scale" : 0
    }
{code}
which unfortunately contains logical avro type.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to