Skip to content

[jdbc-v2] getColumns() returns IS_NULLABLE as LowCardinality(String) on server 26.12 with jdbc_metadata_use_show_statements=false #3486

Backlog

Description

@polyglotAI-bot

Description

With jdbc_metadata_use_show_statements=false, DatabaseMetaData.getColumns() on server 26.12 returns a result set whose IS_NULLABLE column has the type name LowCardinality(String). With the default jdbc_metadata_use_show_statements=true, and on servers before 26.12, the type name is String. The values (YES, NO) and getColumnType() (12, VARCHAR) do not change. So the two metadata paths of jdbc-v2 no longer return the same result-set metadata, and the type name depends on the server version.

This makes the workflow "Test with CH HEAD" red on main: its jdbc-v2 leg failed in all 8 runs since 2026-11-30 16:20Z, for example https://github.com/ClickHouse/clickhouse-java/actions/runs/46767515864/job/143072067119. ShowStatementDatabaseMetaDataTest.testShowStatementsReturnSameMetadataAsSystemTables compares the two paths and fails in its 8 getColumns cases, also through ShowStatementDatabaseMetaDataWithEmptyFormatTest (16 failures). The latest legs of build.yml will fail in the same way when 26.12 is the latest release.

The server change: 26.11 added the setting optimize_if_transform_const_strings_to_lowcardinality (ClickHouse/ClickHouse#80263), and 26.12 enables it by default (system.settings_changes). With it, if, multiIf and transform with constant string branches return LowCardinality(String).

Root cause: getColumnsImpl builds IS_NULLABLE as position(upper(type), 'NULLABLE') >= 1 ? 'YES' : 'NO' (jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java:1169), which is such an expression. The SHOW path declares IS_NULLABLE String (ShowStatementsMetaData.java:56). No other metadata query of jdbc-v2 has a conditional with constant string branches.

The fix is one CAST to String in that query. Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.

Steps to reproduce

  1. Start a ClickHouse server 26.12 (the head build).
  2. Run the program of "Code Example" with jdbc-v2 of main on the class path, and CLICKHOUSE_JDBC_URL set to the server.
  3. Compare the type name of IS_NULLABLE for the two values of jdbc_metadata_use_show_statements.

The server alone:

SELECT toTypeName(if(number > 0, 'YES', 'NO')) FROM numbers(1);
-- LowCardinality(String)
SELECT toTypeName(if(number > 0, 'YES', 'NO')) FROM numbers(1)
SETTINGS optimize_if_transform_const_strings_to_lowcardinality = 0;
-- String

Error Log or Exception StackTrace

jdbc_metadata_use_show_statements=true: IS_NULLABLE type=String, value=NO
jdbc_metadata_use_show_statements=false: IS_NULLABLE type=LowCardinality(String), value=NO

In CI:

[ERROR]   ShowStatementDatabaseMetaDataTest.testShowStatementsReturnSameMetadataAsSystemTables:128 Lists differ at element [17]: IS_NULLABLE:12:LowCardinality(String):0 != IS_NULLABLE:12:String:0 expected [IS_NULLABLE:12:LowCardinality(String):0] but found [IS_NULLABLE:12:String:0]

Expected Behaviour

IS_NULLABLE has the type name String with each value of jdbc_metadata_use_show_statements and with each server version, as the SHOW path declares it.

A tested workaround: the connection property clickhouse_setting_optimize_if_transform_const_strings_to_lowcardinality=0 gives String again. Servers before 26.11 do not have this setting.

Code Example

Reproduction program (Java, 20 lines)
import java.sql.*;
import java.util.Properties;

public class Repro {
    public static void main(String[] args) throws Exception {
        com.clickhouse.jdbc.Driver.load(); // jdbc-v2; the clickhouse-jdbc artifact registers it on its own
        String url = System.getenv().getOrDefault("CLICKHOUSE_JDBC_URL", "jdbc:clickhouse://localhost:8123/default");
        for (String flag : new String[] {"true", "false"}) {
            Properties p = new Properties();
            p.setProperty("jdbc_metadata_use_show_statements", flag);
            try (Connection c = DriverManager.getConnection(url, p);
                 ResultSet rs = c.getMetaData().getColumns(null, "system", "one", null)) {
                int i = rs.findColumn("IS_NULLABLE");
                rs.next();
                System.out.println("jdbc_metadata_use_show_statements=" + flag + ": IS_NULLABLE type="
                        + rs.getMetaData().getColumnTypeName(i) + ", value=" + rs.getString(i));
            }
        }
    }
}

Configuration

Client Configuration

jdbc_metadata_use_show_statements=false

Environment

  • Cloud
  • Client version: main at 27d63e9 (0.12.0-rc1-SNAPSHOT); v0.11.3 has the same query
  • Language version: OpenJDK 17.0.21.1
  • OS: Linux (container), and the GitHub runner of "Test with CH HEAD"

ClickHouse Server

  • ClickHouse Server version: 26.12.1.1280 (head build)
  • ClickHouse Server non-default settings, if any: none
  • CREATE TABLE statements for tables involved: none (system.one)
  • Sample data for all these tables: none

Classification: impact: none · area: API & diagnostics (DatabaseMetaData.getColumns)


Found by automated analysis (Polyglot AI) while working on the red "Test with CH HEAD" runs of main. Verified against a live server.

Activity

  1. added
    jdbc
    jdbc-metadata
    api-diagnostics
    on Dec 2, 2026
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

    api-diagnosticsbugjdbcjdbc-metadata

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions