clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

Selecting huge numbers gives incorrect results

Open ne1r0n opened this issue 3 years ago • 1 comments

Driver version v0.3.2-patch11

Selecting some huge numbers gives incorrect results. For example: SELECT toUInt64(15369343623947579499) a, toNullable(15369343623947579499) b;

in dBeaver: image

in DataGrip: image

ne1r0n avatar Sep 13 '22 09:09 ne1r0n

Thanks @ne1r0n for reporting the issue. I can reproduce the same issue on latest DBeaver but it works in other DB client like SQuirreL SQL.

Behind the scene, by default JDBC driver maps UInt64 to Java long so you may see negative value when calling ResultSet.getLong() but you should really call ResultSet.getObject() or ResultSet.getBigDecimal() instead.

zhicwu avatar Sep 13 '22 09:09 zhicwu

In refactored version, I added Unsigned* classes for unsigned data types(e.g. com.clickhouse.client.data.UnsignedLong for UInt64). This was mainly to fix type conversion issues but it may resolve the display issue in most database clients using the driver as well(DataGrip now shows correct result and same for DBeaver).

zhicwu avatar Nov 10 '22 00:11 zhicwu

The issue has been fixed in JDBC driver, but it looks like DBeaver has display issue - dbeaver/dbeaver#20014

zhicwu avatar May 19 '23 02:05 zhicwu