[ 
https://issues.apache.org/jira/browse/NIFI-972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14939664#comment-14939664
 ] 

Toivo Adams commented on NIFI-972:
----------------------------------

It seems Avro does not support directly null’s for types. Meaning for example 
String type cannot be null.
But Avro offers Union types. Union type allow value be either null or some 
other type, for example String.
https://avro.apache.org/docs/1.7.7/spec.html#Unions

So in JdbcCommon.createSchema() method instead of 
builder.name(meta.getColumnName(i)).type().stringType().noDefault();
union must be used
builder.name(meta.getColumnName(i)).type().unionOf().nullBuilder().endNull().and().stringType().endUnion().noDefault();

Or is there a better way?


> ExecuteSQL bug in createSchema() create Arvo Schema method
> ----------------------------------------------------------
>
>                 Key: NIFI-972
>                 URL: https://issues.apache.org/jira/browse/NIFI-972
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Toivo Adams
>
> Jonathan Lyons reported:
> Just getting started with NiFi here. I am attempting to run a static query
> in MySQL using the ExecuteSQL processor. It is set to run on a 5 second
> interval. Since ExecuteSQL appears to need an input flow file I'm using a
> GenerateFlowFile processor to produce a random file every 5 seconds.
> Unfortunately, I'm getting a very vague ArrayIndexOutOfBounds exception
> when I hit play on the flow:
> java.lang.ArrayIndexOutOfBoundsException: 8
> at org.apache.avro.generic.GenericData$Record.put(GenericData.java:129)
> at org.apache.nifi.processors.standard.util.JdbcCommon.convertToAvroStream
> at
> org.apache.nifi.processors.standard.ExecuteSQL$1.process(ExecuteSQL.java:141)
> It’s seem to be bug in createSchema() which creates Arvo schema.
> When createSchema() will encounter unknown type, no Arvo column info will be 
> created. And Arvo schema has less columns than ResultSet row…



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to