Skip to content

JDBC-V2: ResultSet inferred type for arrays is always Object[] #2457

@jnd77

Description

@jnd77

Description

When retrieving a column, whose type is array, the inferred type is always Object[]; for example, it should be Long[] for Array(Int64).

Steps to reproduce

See code below.

Error Log or Exception StackTrace

See failing test below.

Expected Behaviour

Test should pass.

Code Example

  @Test
  void required_testJdbcWithArray() throws Exception {
    final String url = "jdbc:ch://localhost:8123";

    final Properties info = new Properties();
    info.put("user", "default");
    info.put("password", "");

    try (final Connection conn = DriverManager.getConnection(url, info)) {
      conn.prepareStatement("CREATE TABLE test_array_table"
          + " (id Int64, array_field Array(Int64)) ENGINE = MergeTree() ORDER BY id").execute();
      conn.prepareStatement("INSERT INTO test_array_table VALUES (1, [1,2,3])").execute();
      try (final Statement tableStatement = conn.createStatement();
      final ResultSet resultSet = tableStatement.executeQuery("SELECT `array_field` FROM `test_array_table`")) {
        resultSet.next();
        final Array columnValue = resultSet.getArray(1);
        // The 2 assertions below should pass: instead we retrieve Object[]
        Assertions.assertThat(columnValue.getArray()).isExactlyInstanceOf(Long[].class);
        Assertions.assertThat(JDBCType.valueOf(columnValue.getBaseType())).isEqualTo(JDBCType.BIGINT);
      }
    }
  }

Configuration

Client Configuration

See above.

Environment

  • Cloud
  • Client version:
  • Language version:
  • OS:

ClickHouse Server

  • ClickHouse Server version: 25.3.3.42
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:jdbc-metadataissue handling metadata things like getting type of columnbugjdbc-v2jdbc-v2 issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions