Fix findColumn NullPointerException for unknown column names (return SQLException)#18251
Open
PDGGK wants to merge 1 commit into
Open
Fix findColumn NullPointerException for unknown column names (return SQLException)#18251PDGGK wants to merge 1 commit into
PDGGK wants to merge 1 commit into
Conversation
findColumn returned columnOrdinalMap.get(columnName) directly, so an unknown column name unboxed a null Integer into a NullPointerException instead of the SQLException the JDBC contract (ResultSet.findColumn) requires. Guard the lookup and throw StatementExecutionException (reusing the existing UNKNOWN_COLUMN_NAME message), mirroring the sibling findColumnNameByIndex; the JDBC boundary IoTDBJDBCResultSet.findColumn converts it to SQLException like the existing getBigDecimal path, and SessionDataSet.DataIterator.findColumn propagates the checked exception, consistent with its sibling accessors. Also fixes the identical NPE in IoTDBJDBCDataSet.findColumn. Adds a test asserting an unknown column throws SQLException rather than NPE. Signed-off-by: Zihan Dai <99155080+PDGGK@users.noreply.github.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.
Description
IoTDBRpcDataSet.findColumn(String)returnedcolumnOrdinalMap.get(columnName)directly, so an unknown column name unboxed anullIntegerinto aNullPointerExceptioninstead of theSQLExceptionthat theResultSet.findColumncontract requires. This guards the lookup and throws a checkedStatementExecutionException(reusing the existingUNKNOWN_COLUMN_NAMEmessage), mirroring the siblingfindColumnNameByIndex. The JDBC boundaryIoTDBJDBCResultSet.findColumnconverts it toSQLException(like the existinggetBigDecimalpath), andSessionDataSet.DataIterator.findColumnpropagates the checked exception, consistent with its sibling accessors. The identical NPE in the publicIoTDBJDBCDataSet.findColumnis fixed the same way.A test asserts that an unknown column name throws
SQLExceptionrather thanNullPointerException, and that a valid column name still resolves.This closes #18250.