Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2507#discussion_r174193407
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JdbcCommon.java
---
@@ -859,4 +859,33 @@ public static DateTimeFormatter
getDateTimeFormatter(String pattern) {
void processRow(ResultSet resultSet) throws IOException;
}
+ /**
+ * Returns the table name.
+ *
+ * @param meta
+ * - metadata
+ * @return the table name or an empty string if the driver does not
support
+ * {@link ResultSetMetaData#getTableName(int)}.
+ */
+ private static String getTableNameFromMeta(final ResultSetMetaData
meta) {
+ try {
+ return meta.getTableName(1);
+ } catch (SQLException e) {
+ return "";
--- End diff --
Not having the table name can cause problems with state in the DB fetch
processors. If you have two tables with the same max-value column name, the
state can get corrupted since we use the table name + column name as a key to
store the max value (and column type). In
[HiveJdbcCommon](https://github.com/apache/nifi/blob/rel/nifi-1.5.0/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/util/hive/HiveJdbcCommon.java#L204)
we know it's a Hive ResultSet so we can get the table name as the prefix of
each column name, and each column name as the suffix.
Ideally, at least for the DB fetch processors, we'd have a Hive DB Adapter
like we do for Oracle, MySQL, etc. and we can ask it to give us the table name
from the metadata (and also whether isSigned is supported). That was the goal
of #1281 , but in order to support ExecuteSQL, he added the Database Adapter
property and had it become a "DB fetch processor" in order to use some of the
other common logic.
What do you think about starting with #1281, creating your own branch from
it, rebasing against master, and fixing whatever issues you find? That PR has
the same issue with setQueryTimeout so I'd like to see that handled using the
approach from #2138.
---