@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());
      Assert.assertFalse("excluded parameter key is found in the response",
          retPartition.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key1"));
      Assert.assertFalse("excluded parameter key is found in the response",
          retPartition.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key2"));
      Assert.assertEquals("Additional parameters returned",
          3, retPartition.getParameters().size());
    }
  }
Tests for getPartitionsWithSpecs metastore API. This test create some partitions and makes sure
that getPartitionsWithSpecs returns results which are comparable with the get_partitions API when
various combinations of projection spec are set. Also checks the JDO code path in addition to
directSQL code path
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestGetPartitionsUsingProjectionAndFilterSpecs.java