Skip to content

Throw SQLException for out-of-range column in Arrow getObject#1557

Open
sreekanth-db wants to merge 1 commit into
mainfrom
fix-arrow-getobject-out-of-range
Open

Throw SQLException for out-of-range column in Arrow getObject#1557
sreekanth-db wants to merge 1 commit into
mainfrom
fix-arrow-getobject-out-of-range

Conversation

@sreekanth-db

Copy link
Copy Markdown
Collaborator

Summary

  • ArrowStreamResult.getObject(int) did columnInfos.get(columnIndex) with no bounds check, so an out-of-range column index leaked a raw java.lang.IndexOutOfBoundsException (null SQLState) — a JDBC-contract violation (getObject on a bad column must throw SQLException).
  • Every other result impl (StreamingColumnarResult, StreamingInlineArrowResult, ColumnarRowView, LazyThriftResult, InlineJsonResult, …) already guards the index and throws a DatabricksSQLException(INVALID_STATE, "Column index out of bounds: <n>"). ArrowStreamResult was the lone outlier.
  • Fix: add the same guard to ArrowStreamResult.getObject. This affects the Arrow/CloudFetch result path — used by SEA (all query results) and by Thrift CloudFetch results.

Impact

  • Out-of-range getObject(int) on the Arrow path now throws DatabricksSQLException (SQLState INVALID_STATE, message Column index out of bounds: <n>) instead of a raw IndexOutOfBoundsException. Valid indices are unaffected. Matches the message/SQLState the Thrift columnar path already emits.

Test plan

  • Added ArrowStreamResultTest.testGetObjectOutOfRangeColumnThrowsSqlException (too-high and negative indices → DatabricksSQLException, SQLState=INVALID_STATE). ArrowStreamResultTest passes (21/21).
  • Verified against a warehouse over both transports and both paths (inline + CloudFetch): getObject(<out-of-range>) now returns DatabricksSQLException / INVALID_STATE / "Column index out of bounds: 998" on all four (previously the SEA/Arrow paths threw a raw IndexOutOfBoundsException).

ArrowStreamResult.getObject(int) called columnInfos.get(columnIndex) with no
bounds check, so an out-of-range column index leaked a raw
java.lang.IndexOutOfBoundsException (null SQLState) — a JDBC-contract
violation. Every other result implementation (Thrift columnar/inline, inline
JSON) already guards the index and throws a DatabricksSQLException.

Add the same guard to ArrowStreamResult.getObject so it throws a
DatabricksSQLException (SQLState INVALID_STATE, "Column index out of bounds:
<n>"), matching the other impls. This affects the Arrow/CloudFetch result
path used by SEA and by Thrift CloudFetch results. Added a unit test in
ArrowStreamResultTest covering too-high and negative indices.

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