Skip to content

Throw SQLException for wrong complex-type getter calls#1561

Open
sreekanth-db wants to merge 1 commit into
databricks:mainfrom
sreekanth-db:fix/complex-getter-type-mismatch-sqlexception
Open

Throw SQLException for wrong complex-type getter calls#1561
sreekanth-db wants to merge 1 commit into
databricks:mainfrom
sreekanth-db:fix/complex-getter-type-mismatch-sqlexception

Conversation

@sreekanth-db

Copy link
Copy Markdown
Collaborator

Summary

  • Add instanceof guards in getArray, getStruct, and getMap so a type mismatch throws DatabricksSQLException with the existing COMPLEX_DATA_TYPE_*_CONVERSION_ERROR SQLState instead of an unchecked ClassCastException.
  • Preserve SQL NULL handling (still returns null) and existing disabled/inline-mode guards.
  • Add unit regression coverage and fix testGetMap to mock DatabricksMap (the runtime type the driver returns).

Test plan

  • mvn test -pl jdbc-core -Dtest=DatabricksResultSetTest
  • Live repro: wrong complex getters throw DatabricksSQLException with correct SQLState; NULL array column still returns null

Replace unchecked ClassCastException with DatabricksSQLException when
getArray, getStruct, or getMap is called on a column of a different
complex type, matching JDBC getter error handling.

Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
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.

1 participant