pan3793 commented on code in PR #52988:
URL: https://github.com/apache/spark/pull/52988#discussion_r2512694648
##########
sql/connect/client/jdbc/src/test/scala/org/apache/spark/sql/connect/client/jdbc/SparkConnectJdbcDataTypeSuite.scala:
##########
@@ -248,4 +248,59 @@ class SparkConnectJdbcDataTypeSuite extends
ConnectFunSuite with RemoteSparkSess
}
}
}
+
+ test("getter functions column index out of bound") {
+ Seq(
+ ("'foo'", (rs: ResultSet) => rs.getString(999)),
+ ("true", (rs: ResultSet) => rs.getBoolean(999)),
+ ("cast(1 as byte)", (rs: ResultSet) => rs.getByte(999)),
+ ("cast(1 as short)", (rs: ResultSet) => rs.getShort(999)),
+ ("cast(1 as int)", (rs: ResultSet) => rs.getInt(999)),
+ ("cast(1 as bigint)", (rs: ResultSet) => rs.getLong(999)),
+ ("cast(1 as float)", (rs: ResultSet) => rs.getFloat(999)),
+ ("cast(1 as double)", (rs: ResultSet) => rs.getDouble(999)),
+ ("cast(1 as DECIMAL(10,5))", (rs: ResultSet) => rs.getBigDecimal(999))
+ ).foreach {
+ case (query, getter) =>
+ withExecuteQuery(s"SELECT $query") { rs =>
+ assert(rs.next())
+ withClue("SQLException is not thrown when the result set index goes
out of bound") {
+ intercept[SQLException] {
+ getter(rs)
+ }
Review Comment:
please check the returned message for `SQLException`
nit: I feel the logic here is simple and clear enough, `withClue` may not be
required.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]