-
Notifications
You must be signed in to change notification settings - Fork 607
Description
Describe your feedback
I’m currently working on upgrading the ClickHouse client in Trino from version 0.7.1-patch1 to 0.9.2 #26735.
In the Trino ClickHouse connector, we rely on ClickHouseClientOption.USE_BINARY_STRING. However, in the V2 client, the USE_BINARY_STRING option is no longer supported.
Could you please confirm if there are any plans to support USE_BINARY_STRING
(or an equivalent option) in the V2 client?
Use Case:
In ClickHouse
CREATE TABLE test (col_1 String) Engine = Log;
Insert into test values ('Hello ClickHouse');
We are using getBytes
(because the value can contain an arbitrary set of bytes, including null bytes as per https://clickhouse.com/docs/sql-reference/data-types/string) to get String, FixedString type data from the result set. By default, we map String
, FixedString
as Varbinary
in Trino.
Code example
public class ClickHouseConnect
{
public static void main(String[] args)
throws SQLException
{
ClickHouseDriver driver = new ClickHouseDriver();
Properties properties = new Properties();
properties.setProperty(USE_BINARY_STRING.getKey(), "true");
properties.setProperty("user", "test");
properties.setProperty("password", "test");
Connection connection = driver.connect("jdbc:clickhouse://localhost:33280/default", properties);
ResultSet resultSet = connection.createStatement().executeQuery("Select * from test");
while (resultSet.next()) {
resultSet.getBytes("col_1");
}
connection.close();
}
}
So when we are trying to upgrade from 0.7.1-patch1 to 0.9.2, we are getting below error:
Caused by: java.sql.SQLException: Method: getBytes("col_1") encountered an exception.
at com.clickhouse.jdbc.internal.ExceptionUtils.toSqlState(ExceptionUtils.java:69)
at com.clickhouse.jdbc.ResultSetImpl.getBytes(ResultSetImpl.java:399)
at com.clickhouse.jdbc.ResultSetImpl.getBytes(ResultSetImpl.java:210)
at io.opentelemetry.instrumentation.jdbc.internal.OpenTelemetryResultSet.getBytes(OpenTelemetryResultSet.java:112)
at io.trino.plugin.jdbc.StandardColumnMappings.lambda$varbinaryReadFunction$0(StandardColumnMappings.java:350)
at io.trino.plugin.jdbc.JdbcPageSource.getNextSourcePage(JdbcPageSource.java:206)
... 20 more
Caused by: com.clickhouse.client.api.ClientException: Column is not of array type
at com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader.getPrimitiveArray(AbstractBinaryFormatReader.java:572)
at com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader.getByteArray(AbstractBinaryFormatReader.java:581)
at com.clickhouse.jdbc.ResultSetImpl.getBytes(ResultSetImpl.java:393)
... 24 more