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.
---