Skip to content

jdbc-v2: BigQuery table engine is not mapped in DatabaseMetaDataImpl.ENGINE_TO_TABLE_TYPE #3049

Description

@polyglotAI-bot

Description

The BigQuery table engine, added to ClickHouse server (present in system.table_engines on 26.8), is missing from ENGINE_TO_TABLE_TYPE in jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java (map built at lines 776-893).

Two consequences:

  1. The repo's own completeness test DatabaseMetaDataTest#testAllTableEnginesFromSystemTableEnginesAreMapped fails against a 26.8 server.
  2. DatabaseMetaData#getTables reports TABLE_TYPE = TABLE for a BigQuery-engine table (the getOrDefault fallback at line 908), and such a table is not returned when the caller asks for types = {"REMOTE TABLE"}. Every other external integration engine (URL, MySQL, S3, Iceberg, MongoDB, ...) is mapped to REMOTE TABLE.

Steps to reproduce

  1. Start a ClickHouse server that has the BigQuery engine (verified on 26.8.1.1307; not present on 26.7).
  2. Run DatabaseMetaDataTest#testAllTableEnginesFromSystemTableEnginesAreMapped — it fails.
  3. Create a BigQuery-engine table and read its TABLE_TYPE through DatabaseMetaData#getTables — it is TABLE.

Error Log or Exception StackTrace

DatabaseMetaDataTest.testAllTableEnginesFromSystemTableEnginesAreMapped:702
All table engines from system.table_engines must be mapped in
DatabaseMetaDataImpl.ENGINE_TO_TABLE_TYPE or handled by System/Async prefix.
Unmapped engines: [BigQuery] expected [true] but found [false]

Expected Behaviour

The server reports the engine, so the driver must map it:

$ curl "http://<server>:8123/?query=SELECT name FROM system.table_engines WHERE name = 'BigQuery' FORMAT TSV"
BigQuery

$ curl "http://<server>:8123/?query=SELECT engine FROM system.tables WHERE name = 'bq_probe' FORMAT TSV"
BigQuery

getTables must report TABLE_TYPE = REMOTE TABLE for a BigQuery table, the same as for the other external integration engines, and the table must be returned when types = {"REMOTE TABLE"} is requested.

Observed instead (probe run against 26.8.1.1307, current main @ 601ade1):

server engine                        = BigQuery
getTables(types = null) TABLE_TYPE   = TABLE           <-- expected REMOTE TABLE
getTables(types = ["REMOTE TABLE"])  = 0 rows          <-- expected 1 row
getTables(types = ["TABLE"])         = 1 row           <-- unexpected
contrast, URL engine TABLE_TYPE      = REMOTE TABLE

Code Example

try (Connection conn = getJdbcConnection(); Statement stmt = conn.createStatement()) {
    stmt.executeUpdate("CREATE TABLE bq_probe (a Int32) ENGINE = BigQuery('proj','ds','tbl','key')");

    DatabaseMetaData dbmd = conn.getMetaData();
    try (ResultSet rs = dbmd.getTables(null, conn.getSchema(), "bq_probe", null)) {
        while (rs.next()) {
            System.out.println(rs.getString("TABLE_TYPE")); // prints TABLE, expected REMOTE TABLE
        }
    }
}

Root cause

DatabaseMetaDataImpl.ENGINE_TO_TABLE_TYPE (static initializer, DatabaseMetaDataImpl.java:777-893) has no BigQuery entry. engineToTableType (line 908) therefore returns the TableType.TABLE default. getEnginesForTableTypes (line 915) also omits it, so the REMOTE TABLE filter in getTables (line 966) never selects it, while the "engines not in our map default to TABLE" filter (line 971) does.

Suggested fix

Add to the "Remote/External tables" block:

map.put("BigQuery", TableType.REMOTE_TABLE.getTypeName());

This is the same maintenance step taken in #2861 and #2950 when the server added new engines. No other engine name in system.table_engines on 26.8.1.1307 is unmapped, so BigQuery is the only addition needed.

Configuration

Environment

  • Cloud
  • Client version: main @ 601ade1 (0.10.0-rc1-SNAPSHOT)
  • Language version: JDK 17.0.18
  • OS: Ubuntu 24.04 (Docker)

ClickHouse Server

  • ClickHouse Server version: 26.8.1.1307 (clickhouse/clickhouse-server:head). Not reproducible on 26.7 — the engine does not exist there.
  • ClickHouse Server non-default settings, if any: none relevant
  • CREATE TABLE statements for tables involved:
CREATE TABLE bq_probe (a Int32) ENGINE = BigQuery('proj','ds','tbl','key');

(The table is created successfully with placeholder arguments; no GCP credentials are needed to reproduce, because only the metadata path is exercised.)


Found by automated analysis of the client while working on an unrelated change, and verified against a live server rather than by inspection.

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions