Skip to content

[jdbc-v2] Fix the type name of Nullable(Tuple(...)) columns - #3383

Open
Indian-boult wants to merge 1 commit into
ClickHouse:mainfrom
Indian-boult:fix/nullable-tuple-type-name
Open

Indian-boult wants to merge 1 commit into
ClickHouse:mainfrom
Indian-boult:fix/nullable-tuple-type-name

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

ClickHouseColumn named a Nullable(Tuple(...)) column one closing parenthesis short, for example Nullable(Tuple(Int32, String). jdbc-v2 returned this name from ResultSetMetaData#getColumnTypeName, Array#getBaseTypeName and Struct#getSQLTypeName. Array#getResultSet() of a Nested value with a Nullable(Tuple(...)) field failed with IllegalArgumentException. client-v2 returned the short name in Client#getTableSchema.

readColumn now reads the closing brackets of the Nullable and LowCardinality wrappers after Array, Map, Nested, Tuple, Variant, JSON, QBit and AggregateFunction, the same as it already does for types without parameters. The type name and the returned index include them. Nullable(JSON(...)) and Nullable(QBit(...)) get the right name too.

Two edge cases change. Map(Nullable(Tuple(...)), String) failed to parse and now parses, the same as Map(Nullable(String), String). The server rejects both. In a type name that the application writes, an element after x Nullable(Tuple(...) ) with a space before the last parenthesis was lost and is now kept. No public API changes.

Closes #3382

Checklist


Note

Medium Risk
Changes core type-string parsing used across JDBC and client metadata; regressions could affect any parameterized nullable column name, though behavior is narrowly scoped and well covered by new tests.

Overview
Fixes truncated SQL type strings for columns wrapped in Nullable(...) or LowCardinality(...) when the inner type is parameterized (Tuple, JSON, QBit, etc.). ClickHouseColumn.readColumn now consumes the wrapper’s closing ) after those branches finish, so getOriginalTypeName() is complete—for example Nullable(Tuple(Int32, String)) instead of a missing final parenthesis.

That full name flows through jdbc-v2 and client-v2 metadata paths (ResultSetMetaData#getColumnTypeName, array/struct type names, Client#getTableSchema) and avoids re-parse failures such as Array#getResultSet() on Nested fields containing nullable tuples.

Tests add unit coverage for nullable shapes inside Array/Map/Tuple and an integration test for nullable tuple metadata on ClickHouse 26.1+.

Reviewed by Cursor Bugbot for commit 8125511. Bugbot is set up for automated code reviews on this repo. Configure here.

ClickHouseColumn.readColumn counts the opening brackets of the Nullable and
LowCardinality wrappers, but only the branch for types without parameters
read the matching closing brackets. The branches for Array, Map, Nested,
Tuple, Variant, JSON, QBit and AggregateFunction ended the type name at
their own closing bracket. So Nullable(Tuple(Int32, String)) was named
Nullable(Tuple(Int32, String) and the returned index pointed at the closing
bracket of the wrapper.

After those branches, read the closing brackets of the wrappers and include
them in the type name and in the returned index.

Closes ClickHouse#3382
@Indian-boult
Indian-boult requested review from a team and mzitnik as code owners November 18, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[jdbc-v2] getColumnTypeName returns Nullable(Tuple(...)) without its last closing parenthesis

1 participant