[client-v2] getTableSchema and insert concatenate the raw table name into SQL — names needing backquotes cannot be used
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- clickhouse, java
- Domain
- backend-api-design, databases
Research direction
Start in Client.java at getTableSchema around line 2010 and insert around line 1592, then trace how their SQL is assembled. Reproduce the issue with the provided my-table example and verify that ordinary names are quoted, pre-quoted names remain unchanged, and both operations succeed for names requiring backquotes.
Written by the indexing model from the issue text.
Description
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).
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 637
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 30
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/clickhouse-java
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
ClickHouse/clickhouse-java#3111 ·
-
area:data-type bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-java#3098 · 1 comment ·
-
bug client-api-v2 test
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
ClickHouse/clickhouse-java#3076 ·
-
area:sql-parser bug client-v1
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
ClickHouse/clickhouse-java#3066 ·
-
area:general bug client-api-v2 jdbc jdbc-v2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-java#3063 ·
All issues in ClickHouse/clickhouse-java
Similar issues
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/flink-agents#1152 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo-graphs#75 ·