This is an automated email from the ASF dual-hosted git repository.
sunchao pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new dc41acdd7cb HIVE-27815: Support update numModifiedRows (#4819)
dc41acdd7cb is described below
commit dc41acdd7cb5c76fbd6d208d4375407670579314
Author: Yuming Wang <[email protected]>
AuthorDate: Thu Oct 26 11:01:16 2023 +0800
HIVE-27815: Support update numModifiedRows (#4819)
---
.../java/org/apache/hive/jdbc/HiveStatement.java | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
index 4c985173f55..1a75f7c0199 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
@@ -358,7 +358,7 @@ public class HiveStatement implements java.sql.Statement {
TGetOperationStatusResp statusResp = null;
// Poll on the operation status, till the operation is complete
- while (!isOperationComplete) {
+ do {
try {
/**
* For an async SQLOperation, GetOperationStatus will use the long
polling approach It will
@@ -398,7 +398,7 @@ public class HiveStatement implements java.sql.Statement {
isLogBeingGenerated = false;
throw new SQLException(e.toString(), "08S01", e);
}
- }
+ } while (!isOperationComplete);
/*
we set progress bar to be completed when hive query execution has
completed
@@ -488,7 +488,7 @@ public class HiveStatement implements java.sql.Statement {
@Override
public int executeUpdate(String sql) throws SQLException {
execute(sql);
- return 0;
+ return getUpdateCount();
}
/*
@@ -687,8 +687,20 @@ public class HiveStatement implements java.sql.Statement {
* client might end up using executeAsync and then call this to check if
the query run is
* finished.
*/
- waitForOperationToComplete();
- return -1;
+ long numModifiedRows = -1L;
+ TGetOperationStatusResp resp = waitForOperationToComplete();
+ if (resp != null) {
+ try {
+ numModifiedRows =
+ (long)
resp.getClass().getDeclaredMethod("getNumModifiedRows").invoke(resp);
+ } catch (Exception ignored) {
+ }
+ }
+ if (numModifiedRows == -1L || numModifiedRows > Integer.MAX_VALUE) {
+ LOG.warn("Invalid number of updated rows: {}", numModifiedRows);
+ return -1;
+ }
+ return (int) numModifiedRows;
}
/*