Repository: hive Updated Branches: refs/heads/master c38b7f88e -> 4a2bfb8be
HIVE-18131 - Truncate table for Acid tables (Eugene Koifman, reviewed by Prasanth Jayachandran) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ab7affea Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ab7affea Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ab7affea Branch: refs/heads/master Commit: ab7affea11d6583aabeb471939771e215ac44f48 Parents: c38b7f8 Author: Eugene Koifman <ekoif...@apache.org> Authored: Mon May 7 11:52:33 2018 -0700 Committer: Eugene Koifman <ekoif...@apache.org> Committed: Mon May 7 11:52:33 2018 -0700 ---------------------------------------------------------------------- .../hadoop/hive/ql/lockmgr/TestDbTxnManager2.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/ab7affea/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java ---------------------------------------------------------------------- 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 1d79242..e06f0a4 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 @@ -2512,4 +2512,19 @@ public class TestDbTxnManager2 { Assert.assertEquals("Unexpected lock count", 1, locks.size()); checkLock(LockType.EXCLUSIVE, LockState.ACQUIRED, "default", "T", null, locks); } + @Test + public void testTruncate() throws Exception { + dropTable(new String[] {"T"}); + CommandProcessorResponse cpr = driver.run("create table T (a int, b int) stored as" + + " orc tblproperties('transactional'='true')"); + checkCmdOnDriver(cpr); + checkCmdOnDriver(driver.run("insert into T values(0,2),(1,4)")); + checkCmdOnDriver(driver.run("truncate table T")); + cpr = driver.compileAndRespond("truncate table T"); + checkCmdOnDriver(cpr); + txnMgr.acquireLocks(driver.getPlan(), ctx, "Fifer");//gets X lock on T + List<ShowLocksResponseElement> locks = getLocks(); + Assert.assertEquals("Unexpected lock count", 1, locks.size()); + checkLock(LockType.EXCLUSIVE, LockState.ACQUIRED, "default", "T", null, locks); + } }