[client-v2] ClickHouseColumn mis-parses a Tuple whose JSON element is not last: later elements are swallowed as JSON parameters
メンテナーはふだん 1 日以内に返信
@polyglotAI-bot がすでに取り組んでいます。
2026年9月25日 から。
評価
調査の方向性
ClickHouseColumn.readColumn の 0.9.5 の 508-516 行、または対応する 0.10.0 のコードから始めて、汎用分岐の前に JSON パラメータがどのように検出されるかを確認します。提供されている ClickHouseColumn.of の再現を再実行し、特に Tuple(JSON, FixedString(3)) と Tuple(JSON, Decimal(10, 2)) を確認します。後続のタプル要素が分離されたままで、隣接する JSON パラメータも正しくパースされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
ClickHouseColumn.of(...) mis-parses a Tuple whose JSON element is not the last one: every element after the JSON up to the next closing parenthesis is swallowed as the JSON column's parameter list. Depending on what follows, the Tuple either silently loses elements or the parse throws Unknown data type.
Reproduced on clickhouse-data 0.9.5 and 0.10.0 (latest published), OpenJDK 17. No server needed.
Reproduce
import com.clickhouse.data.ClickHouseColumn;
ClickHouseColumn c = ClickHouseColumn.of("x", "Tuple(JSON, FixedString(3))");
c.getNestedColumns().size(); // 1 (expected 2)
c.getNestedColumns().get(0).getOriginalTypeName(); // "JSON, FixedString(3)"
ClickHouseColumn.of("x", "Tuple(JSON, Decimal(10, 2))");
// java.lang.IllegalArgumentException: Unknown data type: 2
Output of the snippet above (jshell, same on both versions):
Tuple(JSON, FixedString(3)) -> nested=1 first="JSON, FixedString(3)"
Tuple(JSON, Decimal(10, 2)) -> java.lang.IllegalArgumentException: Unknown data type: 2
Tuple(JSON, Int32) -> nested=2 (ok: nothing with parentheses after JSON)
Tuple(Int32, JSON) -> nested=2 (ok: JSON is last)
Tuple(FixedString(3), JSON) -> nested=2 (ok)
JSON(max_dynamic_paths=10) -> [max_dynamic_paths=10] (ok: the '(' is adjacent)
So the trigger is a non-final JSON element followed, anywhere later in the same Tuple, by a type that has parentheses.
Root cause
ClickHouseColumn.readColumn, 0.9.5 lines 508-516 (0.10.0: from line 553, unchanged):
} else if (args.startsWith(KEYWORD_JSON, i)) {
int index = args.indexOf('(', i + KEYWORD_JSON.length()); // scans to the END of the type string
if (index > i) {
i = ClickHouseUtils.skipBrackets(args, index, len, '(');
String originalTypeName = args.substring(startIndex, i);
...
parseJSONColumn(args.substring(index + 1, i - 1), nestedColumns, parameters);
indexOf('(') starts after the keyword but is not bounded to the next character, so inside a Tuple the ( of a later element is found. skipBrackets then consumes through that element's matching ), the span JSON, FixedString(3) becomes one JSON column, and 3 is fed to parseJSONColumn as its parameters. The enclosing Tuple parser resumes after the swallowed text, sees its own ), and ends with one element fewer.
- With
FixedString(3):parseJSONColumn("3")reads3as a path name, finds no type, and returns silently, so the Tuple is short with no error. - With
Decimal(10, 2):parseJSONColumn("10, 2")reads10as a path name and tries to parse2as its type:Unknown data type: 2.
Impact
Client.getTableSchema() fails for any table containing such a column (second case), or returns a Tuple with fewer nested columns than the type text declares (first case). A writer that serializes from the parsed columns but sends getOriginalTypeName() in a RowBinaryWithNamesAndTypes header then writes short rows against a header that promises more, which corrupts or fails the batch with no indication of the cause.
Suggested fix
Treat ( as the JSON parameter list only when it immediately follows the keyword, e.g. index == i + KEYWORD_JSON.length() (optionally after whitespace), matching the generic branch below it, which only calls readParameters when the current character is (.
- 主要言語
- Java
- スター
- 1.6k
- フォーク
- 638
- 平均マージ
- 2日 14時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ClickHouse/clickhouse-java のほかの issue
-
[examples] Remove old Spring example対応中かも @polyglotAI-bot が 9 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
ClickHouse/clickhouse-java#3111 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug client-api-v2 test
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
ClickHouse/clickhouse-java#3076 ·
メンテナーはふだん 1 日以内に返信
-
area:sql-parser bug client-v1
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
ClickHouse/clickhouse-java#3066 ·
メンテナーはふだん 1 日以内に返信
-
bug client-api-v2 jdbc-v2
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-java#2957 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug client-v1 wontfix
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/clickhouse-java#2895 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
ClickHouse/clickhouse-java の issue をすべて見る
似ている issue
-
bug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
LawnchairLauncher/lawnchair#7360 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Temporal transforms put pre-epoch timestamps at `.999999` into the previous unit対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/iceberg#18371 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
objectionary/hone-maven-plugin#1297 ·
メンテナーはふだん 1 日以内に返信
-
bug documentation iam
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
objectionary/lints#1541 ·
メンテナーはふだん 1 日以内に返信