Repository navigation
Labels
api-diagnosticsArea: public API shape, error reporting, logging, metrics, tracingbugjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)
Milestone
Description
See the following reproducer with explanations. Inner type is reported as SMALLINT, whereas it should be Array(INTEGER) again. Leads to errors down stream. Run with java -ea …
import java.sql.DriverManager;
import java.sql.JDBCType;
import java.sql.SQLException;
import java.util.Properties;
public class App2 {
public static void main(String... a) throws SQLException {
var properties = new Properties();
properties.setProperty("user", "username");
properties.setProperty("password", "password");
try (var con = DriverManager.getConnection("jdbc:clickhouse://localhost:18123", properties);
var stmt = con.createStatement()) {
var rs = stmt.executeQuery("SELECT [1,2,3]");
var meta = rs.getMetaData();
assert meta.getColumnType(1) == JDBCType.ARRAY.getVendorTypeNumber();
rs.next();
var array = rs.getArray(1);
assert array.getBaseType() == JDBCType.SMALLINT.getVendorTypeNumber();
rs.close();
rs = stmt.executeQuery("SELECT [[1,2,3]]");
meta = rs.getMetaData();
assert meta.getColumnType(1) == JDBCType.ARRAY.getVendorTypeNumber();
rs.next();
array = rs.getArray(1);
// This should not hold true, it's an array again and actually materialized as array
assert array.getBaseType() == JDBCType.SMALLINT.getVendorTypeNumber();
var arrayResult = array.getResultSet();
arrayResult.next();
// get the actual array
System.out.println(arrayResult.getObject(2));
// but our system is lured onto the wrong path and fails
System.out.println(arrayResult.getInt(2));
}
}
}Error:
Exception in thread "main" java.sql.SQLException: Value of class [Ljava.lang.Short; cannot be converted to class java.lang.Integer
at com.clickhouse.jdbc.types.ArrayResultSet.convertValue(ArrayResultSet.java:146)
at com.clickhouse.jdbc.types.ArrayResultSet.getValueAsObject(ArrayResultSet.java:168)
at com.clickhouse.jdbc.types.ArrayResultSet.getInt(ArrayResultSet.java:234)
at App2.main(App2.java:36)
Metadata
Metadata
Assignees
Labels
api-diagnosticsArea: public API shape, error reporting, logging, metrics, tracingbugjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)
Activity
chernser commentedon Oct 15, 2026
@polyglotAI-bot fix this
Update JDBC docs for multi-dimensional array element type
Fix jdbc-v2: report the element type of a multi-dimensional array