You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Ilya Soin (Jira)" <ji...@apache.org> on 2024/10/17 17:09:00 UTC

[jira] [Updated] (FLINK-36561) ResultSet.wasNull() does not reflect null values in Flink JDBC Driver

     [ https://issues.apache.org/jira/browse/FLINK-36561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ilya Soin updated FLINK-36561:
------------------------------
    Language:   (was: jav)

> ResultSet.wasNull() does not reflect null values in Flink JDBC Driver
> ---------------------------------------------------------------------
>
>                 Key: FLINK-36561
>                 URL: https://issues.apache.org/jira/browse/FLINK-36561
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / JDBC
>    Affects Versions: 1.18.1, 1.20.0, 1.19.1
>            Reporter: Ilya Soin
>            Priority: Major
>
> As per JDBC [standard|https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/ResultSet.html#wasNull()], {{ResultSet.wasNull()}}
> {quote}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.
> {quote}
> 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|https://github.com/apache/flink/blob/release-2.0-preview1-rc1/flink-table/flink-sql-jdbc-driver/src/main/java/org/apache/flink/table/jdbc/FlinkResultSet.java#L106] 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.
> h4. Proposed solution
> Check if the underlying value accessed with {{FlinkResultSet.get*()}} method is null, and update wasNull accordingly.
> h4. For discussion
> Can we skip null rows in FlinkResultSet.next()?
> h4. Steps to reproduce:
> Add
> {code:java}
> assertTrue(resultSet.wasNull());
> {code}
> after any call to resultSet.get*() in [testStringResultSetNullData()|https://github.com/apache/flink/blob/release-2.0-preview1-rc1/flink-table/flink-sql-jdbc-driver/src/test/java/org/apache/flink/table/jdbc/FlinkResultSetTest.java#L115]. Run the test and see the failed check.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)