Kotlin / dataframe

Structured data processing in Kotlin
https://kotlin.github.io/dataframe/overview.html
Apache License 2.0
763 stars 48 forks source link

JDBC H2, `CHAR(10)` column read as `Char?` instead of `String?` #701

Open Jolanrensen opened 1 month ago

Jolanrensen commented 1 month ago

@zaleslaw From an H2 database, a CHAR(10) column is read as Char? instead of String?

This issue can be reproduced easily by editing the fun `read from huge table`() in h2Test.kt by adding the line: schema.columns["characterCol"]!!.type shouldBe typeOf<String?>() The column contains ["ABC", "DEF", "GHI"] so I gotta agree it's not supposed to be a Char.

I discovered it by exploring whether the DataColumnImpl.type actually matches the types found in DataColumnImpl.values, which mismatches in this case. It might be a good check to do for all type conversions :).

zaleslaw commented 4 weeks ago

@Jolanrensen what kind of dialect is set by default for H2 in your example?

Jolanrensen commented 4 weeks ago

@zaleslaw not sure, I just ran your read from huge table test in h2Test.kt, so looking at that file, the connection URL is created like this: https://github.com/Kotlin/dataframe/blob/e781bf7de70a20513b190b959967195fa4795d7f/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/h2Test.kt#L21