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

ASF GitHub Bot commented on NIFI-5612:
--------------------------------------

GitHub user colindean opened a pull request:

    https://github.com/apache/nifi/pull/3032

    NIFI-5612: Support JDBC drivers that return Long for unsigned ints

    Refactors tests in order to share code repeated in tests and to enable some 
parameterized testing.
    
    MySQL Connector/J 5.1.x in conjunction with MySQL 5.0.x will return a Long 
for ResultSet#getObject when the SQL type is an unsigned integer. This change 
prevents that error from occurring while implementing a more informational 
exception describing what the failing object's POJO type is in addition to its 
string value.
    
    ---
    
    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [X] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [X] Has your PR been rebased against the latest commit within the target 
branch (typically master)?
    
    - [X] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [X] Have you ensured that the full suite of tests is executed via `mvn 
-Pcontrib-check clean install` at the root nifi folder?
    - [X] Have you written or updated unit tests to verify your changes?
    - [ ] ~~If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? ~~
    - [ ] ~~If applicable, have you updated the LICENSE file, including the 
main LICENSE file under nifi-assembly?~~
    - [ ] ~~If applicable, have you updated the NOTICE file, including the main 
NOTICE file found under nifi-assembly?~~
    - [ ] ~~If adding new Properties, have you added .displayName in addition 
to .name (programmatic access) for each of the new properties?~~
    
    ### For documentation related changes:
    - [ ] ~~Have you ensured that format looks appropriate for the output in 
which it is rendered?~~
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/colindean/nifi 
colindean/nifi-5612-unresolvedunionint

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/3032.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3032
    
----
commit a017ff49aadde6dbddc0b89a88880f1a47a9803a
Author: Colin Dean <colin.dean@...>
Date:   2018-09-20T00:27:47Z

    NIFI-5612: Support JDBC drivers that return Long for unsigned ints
    
    Refactors tests in order to share code repeated in tests and to enable
    some parameterized testing.
    
    MySQL Connector/J 5.1.x in conjunction with MySQL 5.0.x will return
    a Long for ResultSet#getObject when the SQL type is an unsigned integer.
    This change prevents that error from occurring while implementing a more
    informational exception describing what the failing object's POJO type
    is in addition to its string value.

----


> org.apache.avro.UnresolvedUnionException: Not in union ["null","int"]: 0
> ------------------------------------------------------------------------
>
>                 Key: NIFI-5612
>                 URL: https://issues.apache.org/jira/browse/NIFI-5612
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.5.0, 1.6.0, 1.7.1
>         Environment: Microsoft Windows, MySQL Enterprise 5.0.80
>            Reporter: Colin Dean
>            Priority: Major
>              Labels: ExecuteSQL, avro, nifi
>
> I'm seeing this when I execute {{SELECT * FROM <tablename>}} on a few tables 
> but not on dozens of others in the same database.
> {code:java}
> 2018-09-13 01:11:31,434 WARN [Timer-Driven Process Thread-8] 
> o.a.n.controller.tasks.ConnectableTask Administratively Yielding 
> ExecuteSQL[id=cf5c0996-eddf-3e05-25a3-c407c5edf990] due to uncaught 
> Exception: org.apache.avro.file.DataFileWriter$AppendWriteException: 
> org.apache.avro.UnresolvedUnionException: Not in union ["null","int"]: 0
> org.apache.avro.file.DataFileWriter$AppendWriteException: 
> org.apache.avro.UnresolvedUnionException: Not in union ["null","int"]: 0
>       at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:308)
>       at 
> org.apache.nifi.processors.standard.util.JdbcCommon.convertToAvroStream(JdbcCommon.java:462)
>       at 
> org.apache.nifi.processors.standard.ExecuteSQL.lambda$onTrigger$1(ExecuteSQL.java:252)
>       at 
> org.apache.nifi.controller.repository.StandardProcessSession.write(StandardProcessSession.java:2625)
>       at 
> org.apache.nifi.processors.standard.ExecuteSQL.onTrigger(ExecuteSQL.java:242)
>       at 
> org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
>       at 
> org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1165)
>       at 
> org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:203)
>       at 
> org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
>       at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
>       at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
>       at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>       at java.lang.Thread.run(Thread.java:745)
> Caused by: org.apache.avro.UnresolvedUnionException: Not in union 
> ["null","int"]: 0
>       at 
> org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:709)
>       at 
> org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:192)
>       at 
> org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:110)
>       at 
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73)
>       at 
> org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:153)
>       at 
> org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:143)
>       at 
> org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:105)
>       at 
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73)
>       at 
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:60)
>       at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:302)
>       ... 15 common frames omitted
> {code}
> I don't know if I can share the database schema – still working with my team 
> on that – but looking at it, I think it has something to do with the 
> signedness of int(1) or tinyint(1) because those two are the only numerical 
> types common to all of the table.
>  
> *Edit 2018-09-24, so that my update doesn't get buried:*
> I am able to reproduce the exception using
>  * Vagrant 2.1.1
>  * Virtualbox 5.2.18 r124319
>  * Ubuntu 18.04
>  * MySQL 5.0.81 (as close as I can get to the 5.0.80 Enterprise Edition in 
> use on the system where I observed this failure first)
>  * MySQL Connector/J 5.1.46
>  * NiFi 1.7.1
> With this table definition and data:
> {code:sql}
> create table fails ( 
>   fails int(1) unsigned NOT NULL default '0' 
> ) ENGINE=InnoDB AUTO_INCREMENT=16527 DEFAULT CHARSET=latin1;
> insert into fails values ();
> {code}
> and an ExecuteSQL processor set up to access that table.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to