From d689ac561eadd848043017112a763d3d26a3857f Mon Sep 17 00:00:00 2001 From: patricker Date: Thu, 16 Feb 2017 14:41:21 -0700 Subject: [PATCH] NIFI-3494: GenerateTableFetch Some JDBC Drivers Have Trouble With Name vs Label Signed-off-by: Matt Burgess This closes #1517 --- .../apache/nifi/processors/standard/GenerateTableFetch.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 48ec403991..a850e74e92 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 @@ -251,7 +251,10 @@ public class GenerateTableFetch extends AbstractDatabaseFetchProcessor { // Update the state map with the newly-observed maximum values ResultSetMetaData rsmd = resultSet.getMetaData(); for (int i = 2; i <= rsmd.getColumnCount(); i++) { - String resultColumnName = rsmd.getColumnName(i).toLowerCase(); + //Some JDBC drivers consider the columns name and label to be very different things. + // Since this column has been aliased lets check the label first, + // if there is no label we'll use the column name. + String resultColumnName = (StringUtils.isNotEmpty(rsmd.getColumnLabel(i))?rsmd.getColumnLabel(i):rsmd.getColumnName(i)).toLowerCase(); String fullyQualifiedStateKey = getStateKey(tableName, resultColumnName); String resultColumnCurrentMax = statePropertyMap.get(fullyQualifiedStateKey); if (StringUtils.isEmpty(resultColumnCurrentMax) && !isDynamicTableName) {