@Override public int size() { return partitionSpec.getSharedSDPartitionSpec().getPartitionsSize(); }
private void getPartitionsWithExpr(List<String> filters, int expectedPartition) throws TException { GetPartitionsRequest request = getGetPartitionsRequest(); GetPartitionsProjectionSpec projectSpec = request.getProjectionSpec(); projectSpec.setFieldList(Arrays.asList("sd.location")); request.getFilterSpec().setFilterMode(PartitionFilterMode.BY_EXPR); request.getFilterSpec().setFilters(filters); GetPartitionsResponse response = client.getPartitionsWithSpecs(request); Assert.assertNotNull(response); if (expectedPartition > 0) { PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec(); Assert.assertNotNull(partitionSpecWithSharedSD); Assert.assertEquals("Invalid number of partitions returned", expectedPartition, partitionSpecWithSharedSD.getPartitionsSize()); } else { Assert.assertTrue( "Partition spec should have been empty since filter doesn't match with any partitions", response.getPartitionSpec().isEmpty()); } }
private void getPartitionsWithNames(List<String> names, int expectedPartitionCount) throws TException { GetPartitionsRequest request = getGetPartitionsRequest(); GetPartitionsProjectionSpec projectSpec = request.getProjectionSpec(); projectSpec.setFieldList(Arrays.asList("sd.location")); request.getFilterSpec().setFilterMode(PartitionFilterMode.BY_NAMES); request.getFilterSpec().setFilters(names); GetPartitionsResponse response = client.getPartitionsWithSpecs(request); Assert.assertNotNull(response); if (expectedPartitionCount > 0) { PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec(); Assert.assertNotNull(partitionSpecWithSharedSD); Assert.assertEquals("Invalid number of partitions returned", expectedPartitionCount, partitionSpecWithSharedSD.getPartitionsSize()); List<Partition> origPartitions = client.getPartitionsByNames(dbName, tblName, names); verifyLocations(origPartitions, partitionSpecWithSharedSD.getSd(), partitionSpecWithSharedSD.getPartitions()); } else { Assert.assertTrue( "Partition spec should have been empty since filter doesn't match with any partitions", response.getPartitionSpec().isEmpty()); } }
private void getPartitionsWithVals(List<String> filters, int expectedPartitions) throws TException { // get partitions from "trusted" API List<Partition> partitions = client.listPartitions(dbName, tblName, filters, (short) -1); GetPartitionsRequest request = getGetPartitionsRequest(); GetPartitionsProjectionSpec projectSpec = request.getProjectionSpec(); projectSpec.setFieldList(Arrays.asList("sd.location")); request.getFilterSpec().setFilterMode(PartitionFilterMode.BY_VALUES); request.getFilterSpec().setFilters(filters); GetPartitionsResponse response = client.getPartitionsWithSpecs(request); Assert.assertNotNull(response); if (expectedPartitions > 0) { PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec(); Assert.assertNotNull(partitionSpecWithSharedSD); Assert.assertEquals("Invalid number of partitions returned", expectedPartitions, partitionSpecWithSharedSD.getPartitionsSize()); verifyLocations(partitions, partitionSpecWithSharedSD.getSd(), partitionSpecWithSharedSD.getPartitions()); } else { Assert.assertTrue( "Partition spec should have been empty since filter doesn't match with any partitions", response.getPartitionSpec().isEmpty()); } }
@Override public int size() { return partitionSpec.getSharedSDPartitionSpec().getPartitionsSize(); }
@Override public int size() { return partitionSpec.getSharedSDPartitionSpec().getPartitionsSize(); }