Github user patricker commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2162#discussion_r143664137
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AbstractDatabaseFetchProcessor.java
 ---
    @@ -240,7 +254,14 @@ public void setup(final ProcessContext context) {
                 // Try a query that returns no rows, for the purposes of 
getting metadata about the columns. It is possible
                 // to use DatabaseMetaData.getColumns(), but not all drivers 
support this, notably the schema-on-read
                 // approach as in Apache Drill
    -            String query = dbAdapter.getSelectStatement(tableName, 
maxValueColumnNames, "1 = 0", null, null, null);
    +            String query;
    +
    +            if(StringUtils.isEmpty(sqlQuery)) {
    +                query = dbAdapter.getSelectStatement(tableName, 
maxValueColumnNames, "1 = 0", null, null, null);
    +            } else {
    +                query=sqlQuery + " WHERE 1=0";
    --- End diff --
    
    @mattyb149 
    
    > If they specify a max-value column in the other property, and it is not 
available in this query, then the getSelectStatement() below doesn't seem like 
it would work as expected
    
    What about if I take the list of maxValueColumns and use those to build the 
equivelant of the "1=0" condition. For example, if our max value column names 
are `x` and `y` I could build a where expression `x <> x AND y <> y`. This 
would ensure the column names were present, and if they aren't an exception 
would be thrown.


---

Reply via email to