Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7171

GenerateTableFetch produces SQLException when table is empty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.10.0, 1.11.2
    • None
    • Extensions
    • None

    Description

      When GenerateTableFetch executes with the following conditions ...

      1. partition size = 0
      2. max value columns are unset
      3. connecting to MS SQL Server
      4. the target table has 0 rows

      ... the processor throws a SQLException "Unable to execute SQL select query SELECT -1 FROM [mydb].[dbo].[tbl_test_01] due to java.sql.SQLException: No rows returned from metadata query: SELECT -1 FROM [mydb].[dbo].[tbl_test_01]" and rolls back the flow file. 

      The issue appears to be introduced in the fix for https://issues.apache.org/jira/browse/NIFI-5855 when -1 was used in place of "COUNT( * )".  For an empty table, the SQL Server driver returns 0 rows for the query "SELECT -1 FROM <table>".  GenerateTableFetch throws a SQLException when the resultset contains 0 rows.

       

      Version details:

      MS SQL Server: 12.0.6108.1

      JDBC Driver: com.microsoft.sqlserver:mssql-jdbc:7.4.1.jre8

      JDBC Class: com.microsoft.sqlserver.jdbc.SQLServerDriver

       

      Edit: 4/30/2020: After further testing, I have replicated this behavior with postgres:8.4 and mysql:8.0.13

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            gregory.kline.arcadia Gregory Kline
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: