Skip to content

[client-v2] getTableSchema and insert concatenate the raw table name into SQL — names needing backquotes cannot be used #3089

Closed

Description

@Marais

Describe the bug

Client.getTableSchema(table, database) and Client.insert(tableName, ...) paste the table name into SQL as-is:

"DESCRIBE TABLE " + table       // Client.java:2010 (0.10.0)
"INSERT INTO " + tableName      // Client.java:1592 (0.10.0)

So a valid table name that needs backquotes, like my-table, fails with a server syntax error even though the table exists.

Steps to reproduce

client.queryAll("CREATE TABLE `my-table` (id Int64) ENGINE = MergeTree ORDER BY id");
client.getTableSchema("my-table", "default");  // server syntax error
client.insert("my-table", data, settings);     // same

Expected behaviour

The parameter is documented as a table name, so the client should quote it when building the SQL:

DESCRIBE TABLE `my-table`
INSERT INTO `my-table`

Back-compat: pre-quoted names (`my-table` passed by the caller) work today as a workaround, so already-quoted input should be detected and passed through unchanged (like JDBC's Statement.enquoteIdentifier).

Configuration

  • client-v2 0.9.5 and 0.10.0 (latest) are both affected.

Additional context

flink-connector-clickhouse uses both methods and currently has to reject table names that need quoting; once this is fixed the connector can lift that restriction (a canary test watches for it).

Activity

  1. added this to the 0.11.0 milestone on Aug 31, 2026
  2. chernser commented on Aug 31, 2026

    @chernser
    Contributor

    Good day, @Marais !

    Thank you for reporting this!

  3. slabko commented on Sep 2, 2026

    @slabko

    Be aware of situations where the table name is nice.table. When calling client.insert("nice.table", data, settings);, you need to determine whether nice.table is the full table name or whether nice is the database name and table is the table name.
    For reference, ClickHouse always assumes that an unquoted, dot-separated table name consists of the database name and the table name. If we go that route, users will still need to quote table names that contain a dot.

  4. chernser commented on Sep 2, 2026

    @chernser
    Contributor

    @slabko I appreciate your comment!

    I remember there was something so we use string as is. And this is the good use-case. In client we do not do assumptions and extra computations because for users it is much safer and easier.

    @Marais then I will not change the code and will update the documentation only.

  5. chernser commented on Sep 25, 2026

    @chernser
    Contributor

    @polyglotAI-bot update documentation

  6. added
    documentation
    client
    and removed on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

clientdocumentation

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions