镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Regression for nullable metadata with JDBC client between 0.9.1 and 0.9.2 #2586

Closed

Description

@NathanEckert

Description

Between 0.9.1 and 0.9.2, there was a regression around the metadata for nullability in the JDBC driver.
Note that this affects only the JDBC client, not the Java HTTP client

Steps to reproduce

  1. Create table with nullable column
  2. Run the sample code

Code Example

I have the following table:

create table
  `nullable_key`
(
  `key_1` Nullable(Int64),
  `key_2` Nullable(Int64),
  `value` String NOT NULL
)
ENGINE = MergeTree()
ORDER BY tuple()
;

INSERT INTO
  `nullable_key`
VALUES
(1, null, 'value_1_null'),
(1, 1, 'value_1_1'),
(2, 2, 'value_2_2'),
(null, 2, 'value_null_2'),
(null, null, 'value_null_null');

I query said table the following way:

    @Test
    void testTypes() throws Exception {
        String databaseName = "tck_db_v1";
        String tableName = "nullable_key";

        Client client = CONFIG.getClient();
        TableSchema schemaFromHttpClient = client.getTableSchema(tableName);

        System.out.println("Schema from ClickHouse HTTP client:" + schemaFromHttpClient);

        for (var col : schemaFromHttpClient.getColumns()) {
            System.out.println(col.getColumnName() + " is nullable: " + col.isNullable());
        }

        final var jdbcUrl = "jdbc:clickhouse:"
                + CONFIG.getClient().getEndpoints().iterator().next()
                + "/" + databaseName;
        final Properties properties = new Properties();
        properties.put("user", "default");
        properties.put("password", "");
        System.out.println("JDBC URL: " + jdbcUrl);
        try (Connection connection = DriverManager.getConnection(jdbcUrl, properties)) {
            final ResultSet columns = connection.getMetaData()
                    .getColumns(
                            null,
                            convertToPattern(databaseName),
                            convertToPattern(tableName),
                            null);
            while (columns.next()) {
                final String name = columns.getString("COLUMN_NAME");
                final boolean isNullable = columns.getBoolean("NULLABLE");
                System.out.println(name + " nullable: " + isNullable);
            }
        }
    }

    private static String convertToPattern(String likePattern) {
        return likePattern.replace("_", "\\_");
    }

On 0.9.1, this returns:

Schema from ClickHouse HTTP client:TableSchema{tableName='nullable_key', databaseName='tck_db_v1', columns=[key_1 Nullable(Int64), key_2 Nullable(Int64), value String], colIndex={key_1=0, key_2=1, value=2}, hasDefaults=false}
key_1 is nullable: true
key_2 is nullable: true
value is nullable: false
JDBC URL: jdbc:clickhouse:http://localhost:32859/tck_db_v1
key_1 nullable: true
key_2 nullable: true
value nullable: false

On 0.9.2, this returns:

Schema from ClickHouse HTTP client:TableSchema{tableName='nullable_key', databaseName='tck_db_v1', columns=[key_1 Nullable(Int64), key_2 Nullable(Int64), value String], colIndex={key_1=0, key_2=1, value=2}, hasDefaults=false}
key_1 is nullable: true
key_2 is nullable: true
value is nullable: false
JDBC URL: jdbc:clickhouse:http://localhost:32859/tck_db_v1
key_1 nullable: false
key_2 nullable: false
value nullable: false

On 0.9.2, the value for plain JDBC differs from the HTTP client, and is also a regression vs 0.9.1

Activity

  1. added this to the 0.9.3 milestone on Sep 16, 2025
  2. chernser commented on Sep 16, 2025

    @chernser
    Contributor

    @NathanEckert
    thank you for the feedback!

    This looks like problem in reading int32 values as boolean. We will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions