Skip to content

Nested arrays report wrong types in 0.11.0 #3190

Closed

Description

@michael-simons

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)

Activity

  1. chernser commented on Oct 15, 2026

    @chernser
    Contributor
  2. added this to the 0.12.0 milestone on Oct 16, 2026
  3. added
    jdbc
    on Oct 16, 2026
  4. added
    api-diagnostics
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api-diagnosticsbugjdbc

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions