Commit c21d5a4
[SPARK-54270][CONNECT] SparkConnectResultSet get* methods should call checkOpen and check index boundary
### What changes were proposed in this pull request?
This PR aims to do a minor correction on the current get* functions from `SparkConnectResultSet` class. As previously discussed in the PR #52947,
>1. For every getter function, if the statement is closed, the ResultSet should be unusable. I have verified this with MySQL driver and Postgresql driver.
>
>2. Right now when index goes out of bound, it throws `java.lang.ArrayIndexOutOfBoundsException`, but based on the specification on `java.sql.ResultSet` which is implemented by `SparkConnectResultSet` class, it should throw `java.sql.SQLException`
>
>```
> * throws SQLException if the columnIndex is not valid;
>```
This PR proposes a unified wrapper function called `getColumnValue(columnIndex: Int)` that aims to wrap the `checkOpen` as well as the index boundary check.
### Why are the changes needed?
Currently the get* functions don't follow the expected behaviors of `java.sql.ResultSet`. It's technically not a big problem, but since the `SparkConnectResultSet` aims to implement the `java.sql.ResultSet` class, it should strictly follow the specification documented on the interface definition.
### Does this PR introduce _any_ user-facing change?
This PR is a small fix related to a new feature introduced recently.
### How was this patch tested?
I added 2 tests each covering a bullet point I named above. These 2 functions calls all the get* functions inside `SparkConnectResultSet` class to make sure the correct exception(java.sql.SQLException) is thrown.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #52988 from cty123/cty123/address-spark-connect-getters.
Lead-authored-by: cty123 <[email protected]>
Co-authored-by: cty <[email protected]>
Signed-off-by: yangjie01 <[email protected]>1 parent 03a0e05 commit c21d5a4
File tree
2 files changed
+84
-59
lines changed- sql/connect/client/jdbc/src
- main/scala/org/apache/spark/sql/connect/client/jdbc
- test/scala/org/apache/spark/sql/connect/client/jdbc
2 files changed
+84
-59
lines changedLines changed: 30 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
79 | 97 | | |
80 | 98 | | |
81 | 99 | | |
| |||
85 | 103 | | |
86 | 104 | | |
87 | 105 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 106 | + | |
94 | 107 | | |
95 | 108 | | |
96 | 109 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 110 | + | |
103 | 111 | | |
104 | 112 | | |
105 | 113 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 114 | + | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 118 | + | |
121 | 119 | | |
122 | 120 | | |
123 | 121 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 122 | + | |
130 | 123 | | |
131 | 124 | | |
132 | 125 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 126 | + | |
139 | 127 | | |
140 | 128 | | |
141 | 129 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 130 | + | |
148 | 131 | | |
149 | 132 | | |
150 | 133 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 134 | + | |
157 | 135 | | |
158 | 136 | | |
159 | 137 | | |
| |||
240 | 218 | | |
241 | 219 | | |
242 | 220 | | |
243 | | - | |
244 | | - | |
245 | | - | |
| 221 | + | |
| 222 | + | |
246 | 223 | | |
247 | | - | |
248 | | - | |
249 | 224 | | |
250 | 225 | | |
251 | 226 | | |
| |||
258 | 233 | | |
259 | 234 | | |
260 | 235 | | |
261 | | - | |
262 | | - | |
263 | | - | |
| 236 | + | |
| 237 | + | |
264 | 238 | | |
265 | | - | |
266 | | - | |
267 | 239 | | |
268 | 240 | | |
269 | 241 | | |
| |||
Lines changed: 54 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
251 | 304 | | |
0 commit comments