Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-36561

ResultSet.wasNull() does not reflect null values in Flink JDBC Driver

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.18.1, 1.20.0, 1.19.1
    • None
    • Table SQL / JDBC
    • None

    Description

      As per JDBC standard, ResultSet.wasNull()

      Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL.

      However, Flink JDBC driver currently does not update the wasNull flag within the FlinkResultSet.get*() methods. Instead, it only sets this flag during iteration over rows fetched from the gateway endpoint. This behavior leads to wasNull returning true only if the entire row is null, not when individual column values are null. Consequently, reading a null value using FlinkResultSet.get*() incorrectly results in wasNull() returning false, which is not compliant with the JDBC specification.

      Proposed solution

      Check if the underlying value accessed with FlinkResultSet.get*() method is null, and update wasNull accordingly.

      For discussion

      Can we skip null rows in FlinkResultSet.next()?

      Steps to reproduce:

      Add

      assertTrue(resultSet.wasNull());
      

      after any call to resultSet.get*() in testStringResultSetNullData(). Run the test and see the failed check.

      Attachments

        Activity

          People

            Unassigned Unassigned
            soin08 Ilya Soin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: