You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2018/07/23 04:20:47 UTC

[1/3] hive git commit: HIVE-20218: make sure Statement.executeUpdate() returns number of rows affected (Eugene Koifman, reviewed by Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master-txnstats 2cbe13313 -> e8d7cdcc3


HIVE-20218: make sure Statement.executeUpdate() returns number of rows affected (Eugene Koifman, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/92ecdd97
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/92ecdd97
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/92ecdd97

Branch: refs/heads/master-txnstats
Commit: 92ecdd97bc183b939d1e074f23f52f96e6fafe25
Parents: cce3a05
Author: Eugene Koifman <ek...@apache.org>
Authored: Sun Jul 22 16:25:57 2018 -0700
Committer: Eugene Koifman <ek...@apache.org>
Committed: Sun Jul 22 16:25:57 2018 -0700

----------------------------------------------------------------------
 .../org/apache/hive/jdbc/TestJdbcDriver2.java   | 31 ++++++++++++++++++++
 .../apache/hive/jdbc/HivePreparedStatement.java |  3 +-
 .../org/apache/hive/jdbc/HiveStatement.java     |  3 +-
 3 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/92ecdd97/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
index 850b2d5..8f552b0 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
@@ -209,6 +209,37 @@ public class TestJdbcDriver2 {
     stmt.close();
   }
 
+
+  @Test
+  public void testExceucteUpdateCounts() throws Exception {
+    Statement stmt =  con.createStatement();
+    stmt.execute("set " + ConfVars.HIVE_SUPPORT_CONCURRENCY.varname + "=true");
+    stmt.execute("set " + ConfVars.HIVE_TXN_MANAGER.varname +
+        "=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
+    stmt.execute("create table transactional_crud (a int, b int) stored as orc " +
+        "tblproperties('transactional'='true', 'transactional_properties'='default')");
+    int count = stmt.executeUpdate("insert into transactional_crud values(1,2),(3,4),(5,6)");
+    assertEquals("Statement insert", 3, count);
+    count = stmt.executeUpdate("update transactional_crud set b = 17 where a <= 3");
+    assertEquals("Statement update", 2, count);
+    count = stmt.executeUpdate("delete from transactional_crud where b = 6");
+    assertEquals("Statement delete", 1, count);
+
+    stmt.close();
+    PreparedStatement pStmt =
+        con.prepareStatement("update transactional_crud set b = ? where a = ? or a = ?");
+    pStmt.setInt(1, 15);
+    pStmt.setInt(2, 1);
+    pStmt.setInt(3, 3);
+    count = pStmt.executeUpdate();
+    assertEquals("2 row PreparedStatement update", 2, count);
+    pStmt.setInt(1, 19);
+    pStmt.setInt(2, 3);
+    pStmt.setInt(3, 3);
+    count = pStmt.executeUpdate();
+    assertEquals("1 row PreparedStatement update", 1, count);
+  }
+
   @AfterClass
   public static void tearDownAfterClass() throws Exception {
     Statement stmt = con.createStatement();

http://git-wip-us.apache.org/repos/asf/hive/blob/92ecdd97/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java b/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
index 77a1797..f86b112 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
@@ -119,8 +119,7 @@ public class HivePreparedStatement extends HiveStatement implements PreparedStat
    */
 
   public int executeUpdate() throws SQLException {
-    super.executeUpdate(updateSql(sql, parameters));
-    return 0;
+    return super.executeUpdate(updateSql(sql, parameters));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hive/blob/92ecdd97/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
index 0b38f9c..89ff514 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java
@@ -511,7 +511,8 @@ public class HiveStatement implements java.sql.Statement {
   @Override
   public int executeUpdate(String sql) throws SQLException {
     execute(sql);
-    return 0;
+    return getUpdateCount();
+    //return getLargeUpdateCount(); - not currently implemented... wrong type
   }
 
   /*


[2/3] hive git commit: HIVE-19416 : merge master into branch (Sergey Shelukhin) 0722

Posted by se...@apache.org.
HIVE-19416 : merge master into branch (Sergey Shelukhin) 0722


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b17a3471
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b17a3471
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b17a3471

Branch: refs/heads/master-txnstats
Commit: b17a3471c93216976a9224c2c827b72e45c9d37d
Parents: 2cbe133 92ecdd9
Author: sergey <se...@apache.org>
Authored: Sun Jul 22 21:02:43 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Sun Jul 22 21:02:43 2018 -0700

----------------------------------------------------------------------
 .../org/apache/hive/jdbc/TestJdbcDriver2.java   | 31 ++++++++++++++++++++
 .../apache/hive/jdbc/HivePreparedStatement.java |  3 +-
 .../org/apache/hive/jdbc/HiveStatement.java     |  3 +-
 3 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[3/3] hive git commit: HIVE-19532 : fix tests for master-txnstats branch - fix build (Sergey Shelukhin)

Posted by se...@apache.org.
HIVE-19532 : fix tests for master-txnstats branch - fix build (Sergey Shelukhin)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e8d7cdcc
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e8d7cdcc
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e8d7cdcc

Branch: refs/heads/master-txnstats
Commit: e8d7cdcc372e14f8a0a664911b5ae6934201e30b
Parents: b17a347
Author: sergey <se...@apache.org>
Authored: Sun Jul 22 21:20:46 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Sun Jul 22 21:20:46 2018 -0700

----------------------------------------------------------------------
 .../hcatalog/listener/DummyRawStoreFailEvent.java   | 16 ++++++++--------
 .../hadoop/hive/ql/stats/StatsUpdaterThread.java    |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/e8d7cdcc/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
----------------------------------------------------------------------
diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
index 1c105d1..be40395 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
@@ -321,10 +321,10 @@ public class DummyRawStoreFailEvent implements RawStore, Configurable {
   }
 
   @Override
-  public void alterTable(String catName, String dbName, String name, Table newTable, String queryValidWriteIds)
+  public Table alterTable(String catName, String dbName, String name, Table newTable, String queryValidWriteIds)
       throws InvalidObjectException, MetaException {
     if (shouldEventSucceed) {
-      objectStore.alterTable(catName, dbName, name, newTable, queryValidWriteIds);
+      return objectStore.alterTable(catName, dbName, name, newTable, queryValidWriteIds);
     } else {
       throw new RuntimeException("Event failed.");
     }
@@ -385,22 +385,22 @@ public class DummyRawStoreFailEvent implements RawStore, Configurable {
   }
 
   @Override
-  public void alterPartition(String catName, String dbName, String tblName, List<String> partVals,
+  public Partition alterPartition(String catName, String dbName, String tblName, List<String> partVals,
                              Partition newPart, String queryValidWriteIds) throws InvalidObjectException, MetaException {
     if (shouldEventSucceed) {
-      objectStore.alterPartition(catName, dbName, tblName, partVals, newPart, queryValidWriteIds);
+      return objectStore.alterPartition(catName, dbName, tblName, partVals, newPart, queryValidWriteIds);
     } else {
       throw new RuntimeException("Event failed.");
     }
   }
 
   @Override
-  public void alterPartitions(String catName, String dbName, String tblName,
+  public List<Partition> alterPartitions(String catName, String dbName, String tblName,
                               List<List<String>> partValsList, List<Partition> newParts,
                               long writeId, String queryValidWriteIds)
       throws InvalidObjectException, MetaException {
     if (shouldEventSucceed) {
-      objectStore.alterPartitions(catName, dbName, tblName, partValsList, newParts, writeId, queryValidWriteIds);
+      return objectStore.alterPartitions(catName, dbName, tblName, partValsList, newParts, writeId, queryValidWriteIds);
     } else {
       throw new RuntimeException("Event failed.");
     }
@@ -736,13 +736,13 @@ public class DummyRawStoreFailEvent implements RawStore, Configurable {
   }
 
   @Override
-  public boolean updateTableColumnStatistics(ColumnStatistics statsObj, String validWriteIds, long writeId)
+  public Map<String, String> updateTableColumnStatistics(ColumnStatistics statsObj, String validWriteIds, long writeId)
       throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
     return objectStore.updateTableColumnStatistics(statsObj, validWriteIds, writeId);
   }
 
   @Override
-  public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj,
+  public Map<String, String> updatePartitionColumnStatistics(ColumnStatistics statsObj,
       List<String> partVals, String validWriteIds, long writeId)
       throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
     return objectStore.updatePartitionColumnStatistics(statsObj, partVals, validWriteIds, writeId);

http://git-wip-us.apache.org/repos/asf/hive/blob/e8d7cdcc/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUpdaterThread.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUpdaterThread.java b/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUpdaterThread.java
index f34cb61..a50ec18 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUpdaterThread.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUpdaterThread.java
@@ -447,7 +447,7 @@ public class StatsUpdaterThread extends Thread implements MetaStoreThread {
     }
     // TODO: we should probably skip updating if writeId is from an active txn
     boolean isTxnValid = (writeIdString == null) || ObjectStore.isCurrentStatsValidForTheQuery(
-        conf, db, tbl, params, statsWriteId , writeIdString, false);
+        conf, params, statsWriteId , writeIdString, false);
     return getExistingStatsToUpdate(existingStats, params, isTxnValid);
   }
 
@@ -472,7 +472,7 @@ public class StatsUpdaterThread extends Thread implements MetaStoreThread {
     }
     // TODO: we should probably skip updating if writeId is from an active txn
     if (writeIdString != null && !ObjectStore.isCurrentStatsValidForTheQuery(
-        conf, db, tbl, params, statsWriteId, writeIdString, false)) {
+        conf, params, statsWriteId, writeIdString, false)) {
       return allCols;
     }
     List<String> colsToUpdate = new ArrayList<>();