You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Colin Dean (JIRA)" <ji...@apache.org> on 2018/11/16 18:29:00 UTC

[jira] [Commented] (NIFI-5828) ExecuteSQL executesql.row.count meaning changes when Max Rows Per Flow File > 0

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

Colin Dean commented on NIFI-5828:
----------------------------------

I've tracked this down.

The number of rows put into {{executesql.row.count}} comes from {{nrOfRows}}, an AtomicLong that's created early and set [here|https://github.com/apache/nifi/blob/102a5288efb2a22cd54815dd7331dfc5826aee91/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AbstractExecuteSQL.java#L270]::

{code:java}
nrOfRows.set(sqlWriter.writeResultSet(resultSet, out, getLogger(), null));
{code}

and the attribute is set [here|https://github.com/apache/nifi/blob/102a5288efb2a22cd54815dd7331dfc5826aee91/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AbstractExecuteSQL.java#L280] 10 lines later:

{code:java}
attributesToAdd.put(RESULT_ROW_COUNT, String.valueOf(nrOfRows.get()));
{code}

It's pretty clear that {{SqlWriter#writeResultSet}} returns the number of rows it wrote. Normally, this would be the whole set. The number of max rows is passed to the DefaultAvroSqlWriter [here|https://github.com/apache/nifi/blob/102a5288efb2a22cd54815dd7331dfc5826aee91/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteSQL.java#L145].

I think that the {{executesql.row.count}} should be in the same boat as the fragment count and added [near the end of the onTrigger|https://github.com/apache/nifi/blob/102a5288efb2a22cd54815dd7331dfc5826aee91/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AbstractExecuteSQL.java#L334].

> ExecuteSQL executesql.row.count meaning changes when Max Rows Per Flow File > 0
> -------------------------------------------------------------------------------
>
>                 Key: NIFI-5828
>                 URL: https://issues.apache.org/jira/browse/NIFI-5828
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: 1.8.0
>         Environment: Linux, MSSQL 2016
>            Reporter: Colin Dean
>            Priority: Major
>              Labels: regression
>
> When *Max Rows Per Flow File* ({{esql-max-rows}}) is set greater than 0 to enable it, the {{executesql.row.count}} attribute on the resulting FlowFiles is not the number of rows in the result set but rather the number of rows in the FlowFile.
> This is a deviation from documented behavior, which is "Contains the number of rows returned in the select query".



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