Fix PreparedStatement.getMetaData() crash for SQL type aliases#1289
Fix PreparedStatement.getMetaData() crash for SQL type aliases#1289gopalldb wants to merge 3 commits into
Conversation
…AR, INTEGER, etc.) The DESCRIBE QUERY path in DatabricksResultSetMetaData used ColumnInfoTypeName.valueOf() directly on server-returned type names, which crashes with IllegalArgumentException for SQL type aliases like VARCHAR, INTEGER, NUMERIC, DEC, REAL, NVARCHAR, and NCHAR that have no corresponding enum entry. Replace valueOf() with DatabricksTypeUtil.getColumnInfoType() which already handles canonical-to-alias mappings, and extend it to cover all missing SQL standard aliases: - VARCHAR/NVARCHAR/NCHAR -> STRING - INTEGER -> INT - NUMERIC/DEC -> DECIMAL - REAL -> FLOAT - VARIANT -> STRING - GEOMETRY/GEOGRAPHY -> their own types - INTERVAL sub-types (multi-word) -> INTERVAL Also fixes incorrect DATE -> TIMESTAMP mapping (DATE is a distinct type). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
…contract Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
msrathore-db
left a comment
There was a problem hiding this comment.
Please test it on a real workspace with a table containing all these data types
sreekanth-db
left a comment
There was a problem hiding this comment.
+1, lets test in on real workspace with all the supported datatypes.
Shall we add this is a mandatory step in claude.md to test any changes on real workspace before raising a PR ?
Local Verification ResultsTested against dogfood warehouse ( Before fix (main branch)
After fix (PR branch)
Note on crash reproductionThe However, the fix is correct — replacing the fragile This comment was generated with GitHub MCP. |
|
Correction on DATE mapping verification: The live test showed The DATE bug is in the text-based path at line 440-465 ( The live dogfood server didn't exercise this text-based path in our test, but the fix is confirmed correct by code review and unit tests (the new This comment was generated with GitHub MCP. |
Summary
Completes the fix for #1064 —
PreparedStatement.getMetaData()throwsIllegalArgumentExceptionfor SQL type aliases.PreparedStatement.getMetaData()triggers a DESCRIBE QUERY internally, and the response type names are mapped viaColumnInfoTypeName.valueOf(). SQL type aliases like VARCHAR, INTEGER, NUMERIC, DEC, REAL, NVARCHAR, NCHAR have no enum entry, causingIllegalArgumentExceptionvalueOf()withDatabricksTypeUtil.getColumnInfoType()which handles all alias mappings and falls back toUSER_DEFINED_TYPEinstead of crashinggetColumnInfoType()to cover all missing SQL standard aliases, plus VARIANT, GEOMETRY, GEOGRAPHY, and multi-word INTERVAL sub-typesBackground: Issue #1064 reported crashes for BIGINT, SMALLINT, TINYINT, INTERVAL, VOID, GEOMETRY, GEOGRAPHY. Some of these (BIGINT, SMALLINT, TINYINT) were already fixed on main by adding enum entries. This PR addresses the remaining aliases and replaces the fragile
valueOf()pattern with a safe mapping function.Test plan
getMetaData()calls succeed (server normalizes aliases, so crash cannot be reproduced live, but fix confirmed by code review and unit tests)Closes #1064
This pull request was AI-assisted by Isaac.