Repository: hive Updated Branches: refs/heads/branch-3 f93f76d18 -> 63abf9be0
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/a7d2fb80 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a7d2fb80 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a7d2fb80 Branch: refs/heads/branch-3 Commit: a7d2fb805ce8725525651c54804511ffe5dfbaee Parents: f93f76d Author: Eugene Koifman <ekoif...@apache.org> Authored: Mon May 7 12:05:19 2018 -0700 Committer: Eugene Koifman <ekoif...@apache.org> Committed: Mon May 7 12:05:19 2018 -0700 ---------------------------------------------------------------------- .../hadoop/hive/ql/lockmgr/TestDbTxnManager2.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/a7d2fb80/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); + } }