Skip to content

[jdbc-v2] incorrect wasNull flag for Array #2266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Onajk opened this issue Apr 1, 2025 · 7 comments · Fixed by #2295
Closed

[jdbc-v2] incorrect wasNull flag for Array #2266

Onajk opened this issue Apr 1, 2025 · 7 comments · Fixed by #2295
Assignees
Labels
Milestone

Comments

@Onajk
Copy link

Onajk commented Apr 1, 2025

Describe the bug

After switching to jdbc-v2 there is a problem of reading Array right after NULL value. After debugging I have discovered that result set of array has wasNull flag set to True which is creating exception on Doobie side which I use to read data from ClickHouse in Scala code.

Steps to reproduce

  1. "SELECT NULL, ['value1', 'value2']"
  2. Check result set for second column (array)

Expected behaviour

In jdbc-v1 for version 0.7.2 there is no wasNull = true flag for that array and I would expect the same for jdbc-v2 for version 0.8.x

Code example

Statement stmt = conn.createStatement();
stmt.executeQuery("""
        SELECT NULL, ['value1', 'value2']
        """);
ResultSet rs = stmt.getResultSet();

And analyze the ResultSet (I don't know the methods since I was checking it in Scala)

Error log

Doobie is returning me NonNullableColumnRead error saying SQL 'NULL' read at column 2 (JDBC type Array) but mapping is to a non-Option type.
I have checked that this error is happening because wasNull flag was True after reading the array. By checking result set I could tell that it has correctly detected that first column is Null and second is array of two String values.

Configuration

"com.clickhouse" % "clickhouse-jdbc" % "0.8.2"

@Onajk Onajk added the bug label Apr 1, 2025
@Onajk
Copy link
Author

Onajk commented Apr 1, 2025

@chernser
Copy link
Contributor

chernser commented Apr 1, 2025

Good day, @Onajk!
Thank you for reporting! We will look into it.

@Paultagoras Paultagoras added this to the 0.8.4 milestone Apr 8, 2025
@mzitnik mzitnik self-assigned this Apr 8, 2025
mzitnik added a commit that referenced this issue Apr 9, 2025
@mzitnik mzitnik mentioned this issue Apr 9, 2025
4 tasks
@mzitnik
Copy link
Contributor

mzitnik commented Apr 9, 2025

Hi @Onajk
I have added a test to try to reproduce the issue. See #2295
Can you confirm that we are referring to the same issue
Feedback will be appreciated.

@Onajk
Copy link
Author

Onajk commented Apr 9, 2025

Hi, you didn't actually read the value of wasNull flag after reading the array. For me driver also reads all the data correctly but the flag is true for wasNull which gives me NonNullableColumnRead from Doobie. Value for array wasn't null so flag should be false after reading the array.

@Onajk
Copy link
Author

Onajk commented Apr 9, 2025

One thing I forgot to mention. ClickHouse version I use is: ver. 24.3.12.76

@mzitnik
Copy link
Contributor

mzitnik commented Apr 10, 2025

@Onajk I made some adjustments.

@Onajk
Copy link
Author

Onajk commented Apr 10, 2025

I believe that's it. Thank you

mzitnik added a commit that referenced this issue Apr 10, 2025
* Adding issue #2266 tests

* Adding to getArray wasNull value change if the retrieve data is null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants