Affects Version/s: 0.4.0
Fix Version/s: 0.5.0
When a table has a column of type "unsigned int", the JDBC type of this column is 4 which is INTEGER. When we create the Avro schema for the result set, we end up creating UNION:["int","null"] for this field.
When we process a row from the result set, the Java type for the value of this column is Long, and when trying to write that Avro record it expects and int and produces the following exception:
ExecuteSQL[id=e7cc632a-4d8f-4362-b5e0-68faefd01c23] ExecuteSQL[id=e7cc632a-4d8f-4362-b5e0-68faefd01c23] failed to process session due to org.apache.avro.file.DataFileWriter$AppendWriteException: org.apache.avro.UnresolvedUnionException: Not in union ["null","int"]: 1: org.apache.avro.file.DataFileWriter$AppendWriteException: org.apache.avro.UnresolvedUnionException: Not in union ["null","int"]: 1
This problem was observed with MySQL and NiFi 0.4.0. To reproduce, create table:
Then create a flow with ExecuteSql -> ConvertAvroToJson -> LogAttribute and use a query of "select * from salaries;".
The problem did not happen testing against 0.3.0. At first glance it appears that fixes in
NIFI-972 may have introduced this regression problem. Prior to that we were not using the union approach in the Avro schema which may have allowed this to work.
We most likely need to factor in ResultSetMetadata.isSigned() when determining the type to use in the Avro schema.