Skip to content

fix(jdbc-v2): throw SQLException for an invalid type name in createArrayOf and createStruct - #3363

Open
smthwentroong wants to merge 2 commits into
ClickHouse:mainfrom
smthwentroong:fix/3347-create-array-struct-sqlexception
Open

smthwentroong wants to merge 2 commits into
ClickHouse:mainfrom
smthwentroong:fix/3347-create-array-struct-sqlexception

Conversation

@smthwentroong

@smthwentroong smthwentroong commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Connection.createArrayOf(typeName, ...) and Connection.createStruct(typeName, ...) threw an unchecked IllegalArgumentException or NumberFormatException when the type-name parser rejected typeName. Both methods declare throws SQLException. Thus a catch (SQLException e) block and frameworks that translate SQLException did not get the error.

Changes:

  • ConnectionImpl parses the type name in a new private helper parseColumnType. The helper wraps a parser exception in SQLException with SQLState HY000. The message contains the type name. The parser exception is the cause.
  • createArrayOf and createStruct use this helper.
  • No change for: typeName == null (SQLFeatureNotSupportedException), a closed connection (08000), a non-Tuple type in createStruct, and valid type names.

User-visible behavior: for a type name that the driver cannot parse, the two methods throw SQLException instead of IllegalArgumentException / NumberFormatException.

Compatibility: a caller that catches IllegalArgumentException from these two methods now gets SQLException. SQLException is already in both method signatures, so existing code compiles.

Tests:

  • ConnectionTest.testCreateArrayOfAndStructRejectInvalidTypeName: one @DataProvider with 9 rejected type names (unknown type, misspelled type, unknown nested type, unbalanced parentheses, invalid Decimal parameter, empty string). For both methods, the test checks the exact class SQLException, SQLState HY000, the type name in the message, and an IllegalArgumentException cause.
  • The test uses a WireMock endpoint and server_time_zone, so it does not need a ClickHouse server.
  • Without the fix, all 9 cases fail. With the fix, all ConnectionTest unit tests pass (mvn -pl jdbc-v2 -am verify -DskipITs -Dtest=ConnectionTest). I did not run the integration tests locally.

Closes #3347

Checklist


Note

Low Risk
Client-side JDBC error-mapping only; no server or security logic changes, with a minor compatibility shift for code that caught unchecked parser exceptions from these two methods.

Overview
jdbc-v2 now reports unparseable typeName values from createArrayOf and createStruct as checked SQLException (SQLState HY000) instead of bubbling IllegalArgumentException / NumberFormatException from ClickHouseColumn.of. A new parseColumnType helper performs the parse and wraps failures with a message that includes the type name and the original parser exception as the cause.

Unit tests cover nine invalid type-name cases for both methods (WireMock, no real server). Changelog documents the behavior change for issue #3347.

Callers that specifically caught IllegalArgumentException from these paths must handle SQLException instead.

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

@smthwentroong
smthwentroong requested review from a team and mzitnik as code owners November 17, 2026 15:01
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] Connection.createArrayOf / createStruct throw IllegalArgumentException instead of SQLException for an invalid type name

1 participant