[ https://issues.apache.org/jira/browse/NIFI-5604?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16685476#comment-16685476 ]
ASF GitHub Bot commented on NIFI-5604: -------------------------------------- Github user patricker commented on a diff in the pull request: https://github.com/apache/nifi/pull/3075#discussion_r233132498 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java --- @@ -434,48 +448,53 @@ public void onTrigger(final ProcessContext context, final ProcessSessionFactory numberOfFetches = (partitionSize == 0) ? 1 : (rowCount / partitionSize) + (rowCount % partitionSize == 0 ? 0 : 1); } - // Generate SQL statements to read "pages" of data - Long limit = partitionSize == 0 ? null : (long) partitionSize; - final String fragmentIdentifier = UUID.randomUUID().toString(); - for (long i = 0; i < numberOfFetches; i++) { - // Add a right bounding for the partitioning column if necessary (only on last partition, meaning we don't need the limit) - if ((i == numberOfFetches - 1) && useColumnValsForPaging && (maxValueClauses.isEmpty() || customWhereClause != null)) { - maxValueClauses.add(columnForPartitioning + " <= " + maxValueForPartitioning); - limit = null; - } + // If there are no SQL statements to be generated, still output an empty flow file if specified by the user + if (numberOfFetches == 0 && outputEmptyFlowFileOnZeroResults) { + session.transfer((fileToProcess == null) ? session.create() : session.create(fileToProcess), REL_SUCCESS); --- End diff -- @mattyb149 It's not just the `fragment` attributes, I think you should add all the standard attributes. Right now this Flowfile get's routed to success with no attributes at all. I would suggest refactoring this to include all the standard attributes like `tablename`, `offset` etc... just like a real FlowFile would have. This will make it much easier for downstream processors to use this file like normal. I think the existing logic would cause `offset` to be `null`, which would make sense for this scenario too. > Allow GenerateTableFetch to send empty flow files when no rows would be > fetched > ------------------------------------------------------------------------------- > > Key: NIFI-5604 > URL: https://issues.apache.org/jira/browse/NIFI-5604 > Project: Apache NiFi > Issue Type: Improvement > Components: Extensions > Reporter: Matt Burgess > Assignee: Matt Burgess > Priority: Major > > Currently, GenerateTableFetch will not output a flow file if there are no > rows to be fetched. However, it may be desired (especially with incoming flow > files) that a flow file be sent out even if GTF does not generate any SQL. > This capability, along with the fragment attributes from NIFI-5601, would > allow the user to handle this downstream. -- This message was sent by Atlassian JIRA (v7.6.3#76005)