diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java index dd001a67c4..49779e9c44 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java @@ -290,7 +290,13 @@ public class GenerateTableFetch extends AbstractDatabaseFetchProcessor { String columnsClause = null; List maxValueSelectColumns = new ArrayList<>(numMaxValueColumns + 1); - maxValueSelectColumns.add("COUNT(*)"); + + // replace unnecessary row count with -1 stub value when paging is used + if (useColumnValsForPaging) { + maxValueSelectColumns.add("-1"); + } else { + maxValueSelectColumns.add("COUNT(*)"); + } // For each maximum-value column, get a WHERE filter and a MAX(column) alias IntStream.range(0, numMaxValueColumns).forEach((index) -> {