tarak271 commented on code in PR #4859: URL: https://github.com/apache/hive/pull/4859#discussion_r1483940891
########## itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCrudCompactorOnTez.java: ########## @@ -648,6 +646,52 @@ public void secondCompactionShouldBeRefusedBeforeEnqueueing() throws Exception { Assert.assertEquals("ready for cleaning", compacts.get(0).getState()); } + @Test + public void secondCompactionShouldBeRefusedBeforeEnqueueingForPartition() throws Exception { + conf.setBoolVar(HiveConf.ConfVars.COMPACTOR_CRUD_QUERY_BASED, true); + + final String dbName = "default"; + final String tableName = "compaction_test"; + executeStatementOnDriver("drop table if exists " + tableName, driver); + executeStatementOnDriver("CREATE TABLE " + tableName + "(id string, value string) partitioned by(pt string) CLUSTERED BY(id) " + + "INTO 10 BUCKETS STORED AS ORC TBLPROPERTIES('transactional'='true')", driver); + executeStatementOnDriver("alter table " + tableName + " add partition(pt='test')",driver); + executeStatementOnDriver("INSERT INTO TABLE " + tableName + " partition(pt='test') values ('1','one'),('2','two'),('3','three')," + + "('4','four'),('5','five'),('6','six'),('7','seven'),('8','eight'),('9','nine'),('10','ten')," + + "('11','eleven'),('12','twelve'),('13','thirteen'),('14','fourteen'),('15','fifteen'),('16','sixteen')," + + "('17','seventeen'),('18','eighteen'),('19','nineteen'),('20','twenty')", driver); + + executeStatementOnDriver("insert into " + tableName + " partition(pt='test') values ('21', 'value21'),('84', 'value84')," + + "('66', 'value66'),('54', 'value54')", driver); + executeStatementOnDriver( + "insert into " + tableName + " partition(pt='test') values ('22', 'value22'),('34', 'value34')," + "('35', 'value35')", driver); + executeStatementOnDriver("insert into " + tableName + " partition(pt='test') values ('75', 'value75'),('99', 'value99')", driver); + + TxnStore txnHandler = TxnUtils.getTxnStore(conf); + + //Do a compaction directly and wait for it to finish + CompactionRequest rqst = new CompactionRequest(dbName, tableName, CompactionType.MAJOR); + rqst.setPartitionname("pt=test"); + CompactionResponse resp = txnHandler.compact(rqst); + runWorker(conf); + + //Try to do a second compaction on the same table before the cleaner runs. + try { + driver.run("ALTER TABLE " + tableName + " partition(pt='test') COMPACT 'major'"); Review Comment: 1st test case is for non-partitioned table. The newly created one is for partitioned table. I have made a new test case to make it different for partitioned table as issuing compact on a partitioned table is different from non-partitioned table logic wise -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org