Commit edfd357
[SPARK-54108][CONNECT] Revise execute* methods of SparkConnectStatement
### What changes were proposed in this pull request?
This PR revises the following 3 `execute*` methods and one additional `getUpdateCount` method of `SparkConnectStatement` that are defined in `java.sql.Statement`
```java
/**
* Executes the given SQL statement, which returns a single
* {code ResultSet} object.
*<p>
* <strong>Note:</strong>This method cannot be called on a
* {code PreparedStatement} or {code CallableStatement}.
* param sql an SQL statement to be sent to the database, typically a
* static SQL {code SELECT} statement
* return a {code ResultSet} object that contains the data produced
* by the given query; never {code null}
* throws SQLException if a database access error occurs,
* this method is called on a closed {code Statement}, the given
* SQL statement produces anything other than a single
* {code ResultSet} object, the method is called on a
* {code PreparedStatement} or {code CallableStatement}
* throws SQLTimeoutException when the driver has determined that the
* timeout value that was specified by the {code setQueryTimeout}
* method has been exceeded and has at least attempted to cancel
* the currently running {code Statement}
*/
ResultSet executeQuery(String sql) throws SQLException;
/**
* Executes the given SQL statement, which may be an {code INSERT},
* {code UPDATE}, or {code DELETE} statement or an
* SQL statement that returns nothing, such as an SQL DDL statement.
*<p>
* <strong>Note:</strong>This method cannot be called on a
* {code PreparedStatement} or {code CallableStatement}.
* param sql an SQL Data Manipulation Language (DML) statement, such as {code INSERT}, {code UPDATE} or
* {code DELETE}; or an SQL statement that returns nothing,
* such as a DDL statement.
*
* return either (1) the row count for SQL Data Manipulation Language (DML) statements
* or (2) 0 for SQL statements that return nothing
*
* throws SQLException if a database access error occurs,
* this method is called on a closed {code Statement}, the given
* SQL statement produces a {code ResultSet} object, the method is called on a
* {code PreparedStatement} or {code CallableStatement}
* throws SQLTimeoutException when the driver has determined that the
* timeout value that was specified by the {code setQueryTimeout}
* method has been exceeded and has at least attempted to cancel
* the currently running {code Statement}
*/
int executeUpdate(String sql) throws SQLException;
/**
* Executes the given SQL statement, which may return multiple results.
* In some (uncommon) situations, a single SQL statement may return
* multiple result sets and/or update counts. Normally you can ignore
* this unless you are (1) executing a stored procedure that you know may
* return multiple results or (2) you are dynamically executing an
* unknown SQL string.
* <P>
* The {code execute} method executes an SQL statement and indicates the
* form of the first result. You must then use the methods
* {code getResultSet} or {code getUpdateCount}
* to retrieve the result, and {code getMoreResults} to
* move to any subsequent result(s).
* <p>
*<strong>Note:</strong>This method cannot be called on a
* {code PreparedStatement} or {code CallableStatement}.
* param sql any SQL statement
* return {code true} if the first result is a {code ResultSet}
* object; {code false} if it is an update count or there are
* no results
* throws SQLException if a database access error occurs,
* this method is called on a closed {code Statement},
* the method is called on a
* {code PreparedStatement} or {code CallableStatement}
* throws SQLTimeoutException when the driver has determined that the
* timeout value that was specified by the {code setQueryTimeout}
* method has been exceeded and has at least attempted to cancel
* the currently running {code Statement}
* see #getResultSet
* see #getUpdateCount
* see #getMoreResults
*/
boolean execute(String sql) throws SQLException;
/**
* Retrieves the current result as an update count;
* if the result is a {code ResultSet} object or there are no more results, -1
* is returned. This method should be called only once per result.
*
* return the current result as an update count; -1 if the current result is a
* {code ResultSet} object or there are no more results
* throws SQLException if a database access error occurs or
* this method is called on a closed {code Statement}
* see #execute
*/
int getUpdateCount() throws SQLException;
```
### Why are the changes needed?
Make the implementation respect the JDBC API specification.
### Does this PR introduce _any_ user-facing change?
No, Connect JDBC Driver is an unreleased feature.
### How was this patch tested?
New UTs are added.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #52810 from pan3793/SPARK-54108.
Authored-by: Cheng Pan <[email protected]>
Signed-off-by: yangjie01 <[email protected]>1 parent 2be1eb7 commit edfd357
File tree
2 files changed
+127
-20
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
+127
-20
lines changedLines changed: 47 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
68 | 75 | | |
69 | | - | |
70 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | | - | |
77 | | - | |
78 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
79 | 99 | | |
80 | 100 | | |
81 | 101 | | |
| |||
123 | 143 | | |
124 | 144 | | |
125 | 145 | | |
126 | | - | |
127 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
128 | 155 | | |
129 | 156 | | |
130 | 157 | | |
| |||
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
0 commit comments