Throw SQLException for out-of-range column in Arrow getObject#1557
Open
sreekanth-db wants to merge 1 commit into
Open
Throw SQLException for out-of-range column in Arrow getObject#1557sreekanth-db wants to merge 1 commit into
sreekanth-db wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ArrowStreamResult.getObject(int)didcolumnInfos.get(columnIndex)with no bounds check, so an out-of-range column index leaked a rawjava.lang.IndexOutOfBoundsException(nullSQLState) — a JDBC-contract violation (getObjecton a bad column must throwSQLException).StreamingColumnarResult,StreamingInlineArrowResult,ColumnarRowView,LazyThriftResult,InlineJsonResult, …) already guards the index and throws aDatabricksSQLException(INVALID_STATE, "Column index out of bounds: <n>").ArrowStreamResultwas the lone outlier.ArrowStreamResult.getObject. This affects the Arrow/CloudFetch result path — used by SEA (all query results) and by Thrift CloudFetch results.Impact
getObject(int)on the Arrow path now throwsDatabricksSQLException(SQLStateINVALID_STATE, messageColumn index out of bounds: <n>) instead of a rawIndexOutOfBoundsException. Valid indices are unaffected. Matches the message/SQLState the Thrift columnar path already emits.Test plan
ArrowStreamResultTest.testGetObjectOutOfRangeColumnThrowsSqlException(too-high and negative indices →DatabricksSQLException,SQLState=INVALID_STATE).ArrowStreamResultTestpasses (21/21).getObject(<out-of-range>)now returnsDatabricksSQLException/INVALID_STATE/"Column index out of bounds: 998"on all four (previously the SEA/Arrow paths threw a rawIndexOutOfBoundsException).