Search in sources :

Example 6 with GetLatestCommittedCompactionInfoRequest

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());
}
Also used : GetLatestCommittedCompactionInfoRequest(org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoRequest) CompactionInfoStruct(org.apache.hadoop.hive.metastore.api.CompactionInfoStruct) GetLatestCommittedCompactionInfoResponse(org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoResponse) Test(org.junit.Test)

Aggregations

GetLatestCommittedCompactionInfoRequest (org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoRequest)6 GetLatestCommittedCompactionInfoResponse (org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoResponse)6 Test (org.junit.Test)6 CompactionInfoStruct (org.apache.hadoop.hive.metastore.api.CompactionInfoStruct)5 FindNextCompactRequest (org.apache.hadoop.hive.metastore.api.FindNextCompactRequest)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)1 AbortTxnRequest (org.apache.hadoop.hive.metastore.api.AbortTxnRequest)1 AddDynamicPartitions (org.apache.hadoop.hive.metastore.api.AddDynamicPartitions)1 AllocateTableWriteIdsRequest (org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsRequest)1 AllocateTableWriteIdsResponse (org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsResponse)1