You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Samu <sa...@koivusolutions.com> on 2021/04/20 09:43:31 UTC

QueryRecord errors

SQL like:produces *ArrayIndexOutOfBoundsException* in /QueryRecord  /in /Nifi
1.13.2/with a simple CSV records like:More investigation:SQL like:works fine
and produces output like:The only difference in those SQLs is the column
used for the group by and in subqueries (slot1 vs slot2). To be more
precise, it is the column location in incoming CSV that makes the difference
together with the group by sentence. The exception in the logs is:Index in
error  /"java.lang.ArrayIndexOutOfBoundsException: 3"/ actually depends on
how many columns there are in group by sentence. So things get more
interesting when you add more columns to group by. For example:works again.
Notice that now there are four columns in group by and slot2 in CSV record
is the fourth column!Or actually, it looks like it is working while in real
life it is not as if you change to CSV to be like (last three columns are
not numbers anymore but letters): you will see an error like this in logs:So
now slot2 column in sub-queries is actually referring to slot5 (defined in
the group by) which is not a number and giving an error. With some type of
data SQL might seem to work but are actually using data from the wrong
columns! These could be very hard to find types of errors as no exceptions
are thrown but calculations can be wrong. This can be easily seen when
changing CSV to be like:and SQL like this:and then no errors are thrown but
the result is not correct:My interpretation is that there is a severe bug in
*QueryRecord processor* when using sub-queries. Columns which should be
referenced in records are mixed with columns in group by sentence!Here is
Nifi template where this can be verified:  QueryRecordTest.xml
<http://apache-nifi-users-list.2361937.n4.nabble.com/file/t1093/QueryRecordTest.xml>   



--
Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/