You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by dk...@apache.org on 2022/03/23 15:26:41 UTC

[hive] branch master updated: HIVE-26053: Non blocking DROP VIEW (Denys Kuzmenko, reviewed by Peter Vary)

This is an automated email from the ASF dual-hosted git repository.

dkuzmenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fc9452  HIVE-26053: Non blocking DROP VIEW (Denys Kuzmenko, reviewed by Peter Vary)
7fc9452 is described below

commit 7fc9452ccd36a12ea54aeec6eaa7f596691ad10d
Author: Denys Kuzmenko <dk...@cloudera.com>
AuthorDate: Wed Mar 23 16:23:36 2022 +0100

    HIVE-26053: Non blocking DROP VIEW (Denys Kuzmenko, reviewed by Peter Vary)
    
    Closes #3116
---
 .../hive/ql/ddl/view/drop/DropViewAnalyzer.java       |  2 +-
 .../hadoop/hive/ql/lockmgr/TestDbTxnManager2.java     | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/view/drop/DropViewAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/view/drop/DropViewAnalyzer.java
index 5b6ba23..d2af22e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/view/drop/DropViewAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/view/drop/DropViewAnalyzer.java
@@ -50,7 +50,7 @@ public class DropViewAnalyzer extends BaseSemanticAnalyzer {
     Table view = getTable(viewName, throwException);
     if (view != null) {
       inputs.add(new ReadEntity(view));
-      outputs.add(new WriteEntity(view, WriteEntity.WriteType.DDL_EXCLUSIVE));
+      outputs.add(new WriteEntity(view, WriteEntity.WriteType.DDL_NO_LOCK)); // see AcidUtils.needsLock(output)
     }
 
     DropViewDesc desc = new DropViewDesc(viewName, ifExists);
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
index c3f4cd6..8e4d6d9 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
@@ -3694,4 +3694,23 @@ public class TestDbTxnManager2 extends DbTxnManagerEndToEndTestBase{
     driver.getFetchTask().fetch(res);
     Assert.assertEquals("Expecting 2 rows and found " + res.size(), 2, res.size());
   }
+
+  @Test
+  public void testDropViewNoLocks() throws Exception {
+    driver.run("drop view if exists v_tab_acid");
+    dropTable(new String[] {"tab_acid"});
+
+    driver.run("create table if not exists tab_acid (a int, b int) partitioned by (p string) " +
+      "stored as orc TBLPROPERTIES ('transactional'='true')");
+    driver.run("insert into tab_acid partition(p) (a,b,p) values(1,2,'foo'),(3,4,'bar')");
+
+    driver.run("create view v_tab_acid partitioned on (p) " +
+      "as select a, p from tab_acid where b > 1");
+
+    driver.compileAndRespond("drop view if exists v_tab_acid");
+    
+    driver.lockAndRespond();
+    List<ShowLocksResponseElement> locks = getLocks();
+    Assert.assertEquals("Unexpected lock count", 0, locks.size());
+  }
 }