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

オープン
#3,089 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
clickhouse, java

調査の方向性

Client.java の getTableSchema の 2010 行付近と insert の 1592 行付近から始め、続いてそれらの SQL がどのように組み立てられているかを追跡します。提供された my-table の例で問題を再現し、通常の名前が引用符で囲まれ、あらかじめ引用符で囲まれた名前が変更されず、backquotes が必要な名前で両方の操作が成功することを確認します。

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Java
スター
1.6k
フォーク
637
平均マージ
2日 12時間
マージ済み PR(30日)
28

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ClickHouse/clickhouse-java のほかの issue

ClickHouse/clickhouse-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。