Search in sources :

Example 16 with GetPartitionsRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsRequest in project hive by apache.

the class TestGetPartitionsUsingProjectionAndFilterSpecs method testParameterExpansion.

@Test
public void testParameterExpansion() throws TException {
    GetPartitionsRequest request = getGetPartitionsRequest();
    GetProjectionsSpec projectSpec = request.getProjectionSpec();
    projectSpec.setFieldList(Arrays.asList("sd.cols", "sd.serdeInfo"));
    GetPartitionsResponse response = client.getPartitionsWithSpecs(request);
    PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec();
    StorageDescriptor sharedSD = partitionSpecWithSharedSD.getSd();
    Assert.assertNotNull("sd.cols were requested but was not returned", sharedSD.getCols());
    Assert.assertEquals("Returned serdeInfo does not match with original serdeInfo", origPartitions.get(0).getSd().getCols(), sharedSD.getCols());
    Assert.assertNotNull("sd.serdeInfo were requested but was not returned", sharedSD.getSerdeInfo());
    Assert.assertEquals("Returned serdeInfo does not match with original serdeInfo", origPartitions.get(0).getSd().getSerdeInfo(), sharedSD.getSerdeInfo());
}
Also used : GetProjectionsSpec(org.apache.hadoop.hive.metastore.api.GetProjectionsSpec) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor) GetPartitionsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionsResponse) GetPartitionsRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsRequest) PartitionSpecWithSharedSD(org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 17 with GetPartitionsRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsRequest in project hive by apache.

the class TestGetPartitionsUsingProjectionAndFilterSpecs method testPartitionProjectionEmptySpec.

@Test
public void testPartitionProjectionEmptySpec() throws Throwable {
    GetPartitionsRequest request = getGetPartitionsRequest();
    GetProjectionsSpec projectSpec = request.getProjectionSpec();
    projectSpec.setFieldList(new ArrayList<>(0));
    projectSpec.setExcludeParamKeyPattern("exclude%");
    GetPartitionsResponse response;
    response = client.getPartitionsWithSpecs(request);
    Assert.assertEquals(1, response.getPartitionSpec().size());
    PartitionSpec partitionSpec = response.getPartitionSpec().get(0);
    PartitionSpecWithSharedSD partitionSpecWithSharedSD = partitionSpec.getSharedSDPartitionSpec();
    StorageDescriptor sharedSD = partitionSpecWithSharedSD.getSd();
    Assert.assertNotNull(sharedSD);
    // everything except location in sharedSD should be same
    StorageDescriptor origSd = origPartitions.get(0).getSd().deepCopy();
    origSd.unsetLocation();
    StorageDescriptor sharedSDCopy = sharedSD.deepCopy();
    sharedSDCopy.unsetLocation();
    Assert.assertEquals(origSd, sharedSDCopy);
    List<PartitionWithoutSD> partitionWithoutSDS = partitionSpecWithSharedSD.getPartitions();
    Assert.assertNotNull(partitionWithoutSDS);
    Assert.assertEquals("Unexpected number of partitions returned", origPartitions.size(), partitionWithoutSDS.size());
    for (int i = 0; i < origPartitions.size(); i++) {
        Partition origPartition = origPartitions.get(i);
        PartitionWithoutSD retPartition = partitionWithoutSDS.get(i);
        Assert.assertEquals(origPartition.getCreateTime(), retPartition.getCreateTime());
        Assert.assertEquals(origPartition.getLastAccessTime(), retPartition.getLastAccessTime());
        Assert.assertEquals(origPartition.getSd().getLocation(), sharedSD.getLocation() + retPartition.getRelativePath());
        validateMap(origPartition.getParameters(), retPartition.getParameters());
        validateList(origPartition.getValues(), retPartition.getValues());
    }
}
Also used : GetProjectionsSpec(org.apache.hadoop.hive.metastore.api.GetProjectionsSpec) Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor) GetPartitionsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionsResponse) GetPartitionsRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsRequest) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec) PartitionSpecWithSharedSD(org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 18 with GetPartitionsRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsRequest in project hive by apache.

the class TestGetPartitionsUsingProjectionAndFilterSpecs method testPartitionProjectionIncludeExcludeParameters.

@Test
public void testPartitionProjectionIncludeExcludeParameters() throws Throwable {
    GetPartitionsRequest request = getGetPartitionsRequest();
    GetProjectionsSpec projectSpec = request.getProjectionSpec();
    projectSpec.setFieldList(Arrays.asList("dbName", "tableName", "catName", "parameters", "values"));
    // test parameter key inclusion using setIncludeParamKeyPattern
    projectSpec.setIncludeParamKeyPattern(EXCLUDE_KEY_PREFIX + "%");
    projectSpec.setExcludeParamKeyPattern("%key1%");
    GetPartitionsResponse response = client.getPartitionsWithSpecs(request);
    PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec();
    Assert.assertNotNull("All the partitions should be returned in sharedSD spec", partitionSpecWithSharedSD);
    PartitionListComposingSpec partitionListComposingSpec = response.getPartitionSpec().get(0).getPartitionList();
    Assert.assertNull("Partition list composing spec should be null since all the " + "partitions are expected to be in sharedSD spec", partitionListComposingSpec);
    for (PartitionWithoutSD retPartion : partitionSpecWithSharedSD.getPartitions()) {
        Assert.assertFalse("excluded parameter key is found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key1"));
        Assert.assertTrue("included parameter key is not found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key2"));
        Assert.assertEquals("Additional parameters returned other than inclusion keys", 1, retPartion.getParameters().size());
    }
}
Also used : GetProjectionsSpec(org.apache.hadoop.hive.metastore.api.GetProjectionsSpec) PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) PartitionListComposingSpec(org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec) GetPartitionsResponse(org.apache.hadoop.hive.metastore.api.GetPartitionsResponse) GetPartitionsRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsRequest) PartitionSpecWithSharedSD(org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 19 with GetPartitionsRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsRequest in project hive by apache.

the class TestGetPartitionsUsingProjectionAndFilterSpecs method runWithInvalidFilterByNames.

private void runWithInvalidFilterByNames() throws TException {
    GetPartitionsRequest request = getGetPartitionsRequest();
    GetProjectionsSpec projectSpec = request.getProjectionSpec();
    projectSpec.setFieldList(Arrays.asList("sd.location"));
    request.getFilterSpec().setFilterMode(PartitionFilterMode.BY_NAMES);
    // filter mode is set but not filters are provided
    client.getPartitionsWithSpecs(request);
}
Also used : GetProjectionsSpec(org.apache.hadoop.hive.metastore.api.GetProjectionsSpec) GetPartitionsRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsRequest)

Aggregations

GetPartitionsRequest (org.apache.hadoop.hive.metastore.api.GetPartitionsRequest)19 GetProjectionsSpec (org.apache.hadoop.hive.metastore.api.GetProjectionsSpec)16 GetPartitionsResponse (org.apache.hadoop.hive.metastore.api.GetPartitionsResponse)15 PartitionSpecWithSharedSD (org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD)14 Test (org.junit.Test)12 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)11 PartitionWithoutSD (org.apache.hadoop.hive.metastore.api.PartitionWithoutSD)9 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)7 Partition (org.apache.hadoop.hive.metastore.api.Partition)6 PartitionListComposingSpec (org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec)4 PartitionSpec (org.apache.hadoop.hive.metastore.api.PartitionSpec)4 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 GetPartitionsFilterSpec (org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec)2 Table (org.apache.hadoop.hive.metastore.api.Table)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConfigValSecurityException (org.apache.hadoop.hive.metastore.api.ConfigValSecurityException)1 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)1