use of org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoRequest in project hive by apache.
the class TestCompactionTxnHandler method testGetLatestCommittedCompaction.
@Test
public void testGetLatestCommittedCompaction() throws Exception {
final String dbName = "foo";
final String tableName = "bar";
final String errorMessage = "Dummy error";
addSucceededCompaction(dbName, tableName, null, CompactionType.MINOR);
addFailedCompaction(dbName, tableName, CompactionType.MINOR, null, errorMessage);
GetLatestCommittedCompactionInfoRequest rqst = new GetLatestCommittedCompactionInfoRequest();
rqst.setDbname(dbName);
rqst.setTablename(tableName);
GetLatestCommittedCompactionInfoResponse response = txnHandler.getLatestCommittedCompactionInfo(rqst);
assertNotNull(response);
assertEquals("Expecting a single compaction record", 1, response.getCompactionsSize());
CompactionInfoStruct lci = response.getCompactions().get(0);
assertEquals("Expecting the first succeeded compaction record", 1, lci.getId());
assertNull("Expecting null partitionname for a non-partitioned table", lci.getPartitionname());
assertEquals(CompactionType.MINOR, lci.getType());
rqst.setPartitionnames(new ArrayList<>());
response = txnHandler.getLatestCommittedCompactionInfo(rqst);
assertNotNull(response);
assertEquals("Expecting a single compaction record", 1, response.getCompactionsSize());
lci = response.getCompactions().get(0);
assertEquals("Expecting the first succeeded compaction record", 1, lci.getId());
assertEquals(dbName, lci.getDbname());
assertEquals(tableName, lci.getTablename());
assertNull("Expecting null partitionname for a non-partitioned table", lci.getPartitionname());
assertEquals(CompactionType.MINOR, lci.getType());
}
Aggregations