rkirtir commented on code in PR #3708:
URL: https://github.com/apache/hive/pull/3708#discussion_r1007694800
##########
ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java:
##########
@@ -2388,6 +2396,65 @@ public void testShowCompactionInputValidation() throws
Exception {
"STATUS 'ready for clean'");//validates compaction status
}
+ @Test
+ public void testShowCompactionFilterSortingAndLimit()throws Exception {
+ runStatementOnDriver("drop database if exists mydb1 cascade");
+ runStatementOnDriver("create database mydb1");
+ runStatementOnDriver("create table mydb1.tbl0 " + "(a int, b int)
partitioned by (p string) clustered by (a) into " +
+ BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES
('transactional'='true')");
+ runStatementOnDriver("insert into mydb1.tbl0" + " PARTITION(p) " +
+ "
values(1,2,'p1'),(3,4,'p1'),(1,2,'p2'),(3,4,'p2'),(1,2,'p3'),(3,4,'p3')");
+ runStatementOnDriver("alter table mydb1.tbl0" + " PARTITION(p='p1')
compact 'MAJOR'");
+ TestTxnCommands2.runWorker(hiveConf);
+ runStatementOnDriver("alter table mydb1.tbl0" + " PARTITION(p='p2')
compact 'MAJOR'");
+ TestTxnCommands2.runWorker(hiveConf);
+
+
+ runStatementOnDriver("drop database if exists mydb cascade");
+ runStatementOnDriver("create database mydb");
+ runStatementOnDriver("create table mydb.tbl " + "(a int, b int)
partitioned by (ds string) clustered by (a) into " +
+ BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES
('transactional'='true')");
+ runStatementOnDriver("insert into mydb.tbl" + " PARTITION(ds) " +
+ "
values(1,2,'mon'),(3,4,'tue'),(1,2,'mon'),(3,4,'tue'),(1,2,'wed'),(3,4,'wed')");
+ runStatementOnDriver("alter table mydb.tbl" + " PARTITION(ds='mon')
compact 'MAJOR'");
+ TestTxnCommands2.runWorker(hiveConf);
+ runStatementOnDriver("alter table mydb.tbl" + " PARTITION(ds='tue')
compact 'MAJOR'");
+ TestTxnCommands2.runWorker(hiveConf);
+
+ runStatementOnDriver("create table mydb.tbl2 " + "(a int, b int)
partitioned by (dm string) clustered by (a) into " +
+ BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES
('transactional'='true')");
+ runStatementOnDriver("insert into mydb.tbl2" + " PARTITION(dm) " +
+ "
values(1,2,'xxx'),(3,4,'xxx'),(1,2,'yyy'),(3,4,'yyy'),(1,2,'zzz'),(3,4,'zzz')");
+ runStatementOnDriver("alter table mydb.tbl2" + " PARTITION(dm='yyy')
compact 'MAJOR'");
+ TestTxnCommands2.runWorker(hiveConf);
+ runStatementOnDriver("alter table mydb.tbl2" + " PARTITION(dm='zzz')
compact 'MAJOR'");
+ TestTxnCommands2.runWorker(hiveConf);
+
+ ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
+
+ //includes Header row
+ List<String> r = runStatementOnDriver("SHOW COMPACTIONS");
+ Assert.assertEquals(rsp.getCompacts().size() + 1, r.size());
+ r = runStatementOnDriver("SHOW COMPACTIONS LIMIT 3");
+ Assert.assertEquals(4, r.size());
+ r = runStatementOnDriver("SHOW COMPACTIONS SCHEMA mydb TYPE 'MAJOR' LIMIT
2");
+ Assert.assertEquals(3, r.size());
+
+ r = runStatementOnDriver("SHOW COMPACTIONS SCHEMA mydb TYPE 'MAJOR' ORDER
BY CC_TABLE DESC, CC_PARTITION ASC");
Review Comment:
Agree.
I have hanged show compaction output like
"CompactionId\tDbname\tTbname\tPartitions\tType\tState\tWorker host\tWorker
And show commanction command with custom sort order would be like(casing
does not matter)
SHOW COMPACTIONS SCHEMA mydb TYPE 'MAJOR' ORDER BY tbname DESC,PARTITIONS ASC
what do you think
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]