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

How to read FixedString back into java

Open tpoll opened this issue 1 year ago • 0 comments

My application has some CH columns I store as FixedString(16) values. When I'm writing them into ClickHouse via JDBC, I pass in a byte array of length 16, and see that my values are properly persisted. However, when I attempt to read the values back out, it seems that the ClickHouseResultSet automatically puts the column into a ClickhouseStringValue. It's then pretty tricky to retrieve this the underlying bytes of the string are the 32 byte representation of the 16 character fixed string.

Is it possible to add some logic in to the client to map FixedString types back out as a byte array? Does anyone have guidance on the best java type to map Fixed string values into and out of with JDBC?

I'm on client version 0.5.0 java version 21.0.1 and CH server version 23.9.x

tpoll avatar Feb 05 '24 23:02 tpoll