tpalfy commented on code in PR #9640:
URL: https://github.com/apache/nifi/pull/9640#discussion_r1924064310
##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-parameter-providers/src/main/java/org/apache/nifi/parameter/DatabaseParameterProvider.java:
##########
@@ -233,8 +223,23 @@ private void validateValueNotNull(final String value,
final String columnName) {
}
String getQuery(final ConfigurationContext context, final String
tableName, final List<String> columns, final String whereClause) {
- final DatabaseAdapter dbAdapter =
dbAdapters.get(context.getProperty(DB_TYPE).getValue());
- return dbAdapter.getSelectStatement(tableName,
StringUtils.join(columns, ", "), whereClause, null, null, null);
+ final String databaseType = context.getProperty(DB_TYPE).getValue();
+ final DatabaseDialectService databaseDialectService =
DatabaseAdapterDescriptor.getDatabaseDialectService(context,
DATABASE_DIALECT_SERVICE, databaseType);
+
+ final List<ColumnDefinition> columnDefinitions = columns.stream()
+ .map(StandardColumnDefinition::new)
+ .map(ColumnDefinition.class::cast)
+ .toList();
+ final TableDefinition tableDefinition = new
TableDefinition(Optional.empty(), Optional.empty(), tableName,
columnDefinitions);
+ final QueryStatementRequest queryStatementRequest = new
StandardQueryStatementRequest(
+ StatementType.SELECT,
+ tableDefinition,
+ Optional.empty(),
+ List.of(new QueryClause(QueryClauseType.WHERE, whereClause)),
+ Optional.empty()
+ );
+ final StatementResponse statementResponse =
databaseDialectService.getStatement(queryStatementRequest);
Review Comment:
When the optional`SQL WHERE clause` property is not set (null), the
generated select statement will have a "WHERE null" clause, resulting in an
exception (at least it did when testing on Oracle).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]