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());
}
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());
}
}
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());
}
}
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);
}
Aggregations