Skip to content

[jdbc-v2] DatabaseMetadata fails if server has a new type #2394

Open

Description

@chernser

Description

Stacktrace:

java.lang.IllegalArgumentException: Unknown data type: Time64
	at com.clickhouse.data.ClickHouseDataType.of(ClickHouseDataType.java:460)
	at com.clickhouse.jdbc.metadata.DatabaseMetaDataTest.testGetTypeInfo(DatabaseMetaDataTest.java:234)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

This means that old client would not work with a new server even if type is never used.

Expected Behaviour

Warning but no exception when client reads a new type from a server.

Activity

  1. added
    jdbc
    on May 28, 2025
  2. added this to the 0.9.0 milestone on May 28, 2025
  3. mshustov commented on May 28, 2025

    @mshustov
    Member

    @chernser, it seems to have been revered ClickHouse/ClickHouse#75735, but agree the client shouldn't fail on a new type

  4. added
    jdbc-metadata
    on Jun 27, 2025
  5. chernser commented on Jun 27, 2025

    @chernser
    ContributorAuthor

    This exception happens actually in the test so its fine. And indicates missing type.
    However we may need to find place where it can cause an error.

  6. removed this from the 0.9.1 milestone on Jul 21, 2025
  7. chernser commented on Dec 17, 2025

    @chernser
    ContributorAuthor

    There is a bug in Metadata reading type info (#2678 (comment)):

    [ERROR] 2025-12-17 15:03:47.935 [main] c.c.j.metadata.DatabaseMetaDataImpl - Failed to convert column data type to SQL type: {}
    java.lang.IllegalArgumentException: No enum constant com.clickhouse.data.ClickHouseDataType.Geometry
            at java.base/java.lang.Enum.valueOf(Enum.java:293)
            at com.clickhouse.data.ClickHouseDataType.valueOf(ClickHouseDataType.java:52)
            at com.clickhouse.jdbc.metadata.DatabaseMetaDataImpl.lambda$static$2(DatabaseMetaDataImpl.java:1102)
            at com.clickhouse.jdbc.internal.DetachedResultSet.createFromResultSet(DetachedResultSet.java:93)
            at com.clickhouse.jdbc.metadata.DatabaseMetaDataImpl.getTypeInfo(DatabaseMetaDataImpl.java:1082)
            at io.github.linghengqian.SimpleTest.simpleTest(SimpleTest.java:14)
    
  8. 3 remaining items

  9. added this to the 0.9.6 milestone on Dec 18, 2025
  10. chernser commented on Dec 18, 2025

    @chernser
    ContributorAuthor

    There is a potential problem with reading data schema containing unknown Datatype.
    We may ignore columns with unknown types but should:

    • create a special ClickhouseColumn instance that indicate unknown column to prevent accidental usage in binary writers and readers
    • write documentation around it
    • configuration flag?? may be not.
  11. modified the milestones: 0.9.6, 0.9.7 on Jan 7, 2026
  12. modified the milestones: 0.9.7, 0.9.8 on Jan 21, 2026
  13. modified the milestones: 0.9.8, 0.9.9 on Mar 16, 2026
  14. added this to the 0.12.0 milestone on Jul 22, 2026
  15. removed this from the 0.12.0 milestone on Nov 10, 2026
  16. added
    data-types
    on Nov 26, 2026
  17. polyglotAI-bot commented on Nov 28, 2026

    @polyglotAI-bot
    Collaborator

    Recommendation: Keep open — maintainer decision
    DatabaseMetaData does not fail on a type that the client does not know, but Client.getTableSchema does: the case of the 2025-12-18 comment. A maintainer decides whether this issue tracks that case, or closes it for the metadata part.

    • Category: Bug
    • Classification: impact: none · area: Data types & formats (unknown type names)
    • Status on main: Reproduced on main — for the table schema only. getTypeInfo and getColumns give OTHER (1111) and log an error for an unknown type (release 0.10.0, which does not know MultiPoint); no exception.
    • Breaking change: No — can be done without a break; today the call fails.
    • Duplicates / related: Related: [jdbc-v2, client-v2] Improve messages for unknown data types #2698 (merged, 0.9.5) — it changed only the messages for unknown types.

    Analysis: getTypeInfo and getColumns catch the error of an unknown type and use OTHER (jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java:1417-1433, :1202-1217); the exception in the issue comes from its test, which calls ClickHouseDataType.of. TableSchemaParser.readTSKV throws ClientException for a column type that it cannot parse (client-v2/src/main/java/com/clickhouse/client/api/internal/TableSchemaParser.java:31-33), so getTableSchema (Client.java:2402) fails for the whole table, also when the caller does not use that column.

    Reproduction: complete program and output
    import com.clickhouse.client.api.internal.TableSchemaParser;
    import java.io.ByteArrayInputStream;
    import java.nio.charset.StandardCharsets;
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.Properties;
    
    public class Repro {
        static final String URL = System.getenv().getOrDefault("CLICKHOUSE_URL", "http://localhost:8123");
        static final String PASSWORD = System.getenv().getOrDefault("CLICKHOUSE_PASSWORD", "");
    
        public static void main(String[] args) throws Exception {
            Properties props = new Properties();
            props.setProperty("user", "default");
            props.setProperty("password", PASSWORD);
            props.setProperty("compress", "false"); // release 0.10.0 cannot read the compressed responses of server 26.11
            String jdbcUrl = "jdbc:clickhouse:" + URL.replaceFirst("^https?:", "") + "/default";
            try (Connection conn = DriverManager.getConnection(jdbcUrl, props)) {
                try (Statement st = conn.createStatement()) {
                    st.execute("DROP TABLE IF EXISTS t2394");
                    st.execute("CREATE TABLE t2394 (id UInt32, mp MultiPoint) ENGINE = Memory");
                }
                DatabaseMetaData md = conn.getMetaData();
                try (ResultSet rs = md.getTypeInfo()) {
                    int rows = 0;
                    String mp = "missing";
                    while (rs.next()) {
                        rows++;
                        if ("MultiPoint".equals(rs.getString("TYPE_NAME"))) mp = String.valueOf(rs.getInt("DATA_TYPE"));
                    }
                    System.out.println("getTypeInfo: rows=" + rows + ", MultiPoint DATA_TYPE=" + mp);
                } catch (Exception e) {
                    System.out.println("getTypeInfo: " + e);
                }
                try (ResultSet rs = md.getColumns(null, "default", "t2394", null)) {
                    StringBuilder sb = new StringBuilder();
                    while (rs.next()) sb.append(rs.getString("COLUMN_NAME")).append(' ').append(rs.getString("TYPE_NAME"))
                            .append(" DATA_TYPE=").append(rs.getInt("DATA_TYPE")).append("; ");
                    System.out.println("getColumns: " + sb);
                } catch (Exception e) {
                    System.out.println("getColumns: " + e);
                }
                try (Statement st = conn.createStatement()) {
                    st.execute("DROP TABLE t2394");
                }
            }
            // Client.getTableSchema() parses the DESCRIBE TABLE rows with TableSchemaParser.readTSKV.
            // No type of the server is unknown to main, so give the parser a row with a type name that the client does not know.
            String describe = "name=id\ttype=UInt32\nname=v\ttype=FutureType\n";
            try {
                int n = TableSchemaParser.readTSKV(new ByteArrayInputStream(describe.getBytes(StandardCharsets.UTF_8)),
                        "t", null, "default").getColumns().size();
                System.out.println("table schema: " + n + " columns");
            } catch (Exception e) {
                System.out.println("table schema: " + e.getClass().getName() + ": " + e.getMessage());
            }
        }
    }

    Output on main (8480ca001), ClickHouse 26.11.4.11:

    getTypeInfo: rows=68, MultiPoint DATA_TYPE=2003
    getColumns: id UInt32 DATA_TYPE=-5; mp MultiPoint DATA_TYPE=2003; 
    table schema: com.clickhouse.client.api.ClientException: Failed to parse column `v` defined by type 'FutureType'
    

    Output on release 0.10.0, ClickHouse 26.11.4.11 (stack traces cut):

    [main] ERROR com.clickhouse.jdbc.metadata.DatabaseMetaDataImpl - Unknown type: MultiPoint. Please check for a new version of the client.
    getTypeInfo: rows=68, MultiPoint DATA_TYPE=1111
    [main] ERROR com.clickhouse.jdbc.metadata.DatabaseMetaDataImpl - Failed to convert column data type to SQL type: {}
    getColumns: id UInt32 DATA_TYPE=-5; mp MultiPoint DATA_TYPE=1111; 
    table schema: com.clickhouse.client.api.ClientException: Failed to parse column `v` defined by type 'FutureType'
    

    Automated triage by Polyglot AI. A maintainer makes the final decision.

  18. added
    client
    on Nov 28, 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

    bugclientdata-typesjdbcjdbc-metadata

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions