### Question:
PartitionProjectionEvaluator { @VisibleForTesting Set<PartitionFieldNode> getRoots() { return roots; } PartitionProjectionEvaluator(PersistenceManager pm,
      ImmutableMap<String, String> fieldNameToTableName, List<String> projectionFields,
      boolean convertMapNullsToEmptyStrings, boolean isView, String includeParamKeyPattern,
      String excludeParamKeyPattern); List<Partition> getPartitionsUsingProjectionList(List<Long> partitionIds); static List<String> getMPartitionFieldNames(List<String> partitionFields);  }### Answer:
@Test public void testPartitionFieldTree() throws MetaException { PersistenceManager mockPm = Mockito.mock(PersistenceManager.class); List<String> projectionFields = new ArrayList<>(2); projectionFields.add("sd.location"); projectionFields.add("sd.parameters"); projectionFields.add("createTime"); projectionFields.add("sd.serdeInfo.serializationLib"); projectionFields.add("sd.cols"); projectionFields.add("parameters"); PartitionProjectionEvaluator projectionEvaluator = new PartitionProjectionEvaluator(mockPm, fieldNameToColumnName, projectionFields, false, false, null, null); Set<PartitionFieldNode> roots = projectionEvaluator.getRoots(); Set<PartitionFieldNode> expected = new HashSet<>(); PartitionFieldNode sdNode = new PartitionFieldNode("sd"); sdNode.addChild(new PartitionFieldNode("sd.location")); sdNode.addChild(new PartitionFieldNode("sd.parameters", true)); PartitionFieldNode sdColsNodes = new PartitionFieldNode("sd.cols", true); sdColsNodes.addChild(new PartitionFieldNode("sd.cols.name", true)); sdColsNodes.addChild(new PartitionFieldNode("sd.cols.type", true)); sdColsNodes.addChild(new PartitionFieldNode("sd.cols.comment", true)); sdNode.addChild(sdColsNodes); PartitionFieldNode serdeNode = new PartitionFieldNode("sd.serdeInfo"); serdeNode.addChild(new PartitionFieldNode("sd.serdeInfo.serializationLib")); sdNode.addChild(serdeNode); expected.add(sdNode); expected.add(new PartitionFieldNode("parameters", true)); expected.add(new PartitionFieldNode("createTime")); expected.add(new PartitionFieldNode("PART_ID")); expected.add(new PartitionFieldNode("SD_ID")); expected.add(new PartitionFieldNode("CD_ID")); expected.add(new PartitionFieldNode("SERDE_ID")); compare(expected, roots); }
@Test public void testProjectionCompaction() throws MetaException { PersistenceManager mockPm = Mockito.mock(PersistenceManager.class); List<String> projectionFields = new ArrayList<>(2); projectionFields.add("sd.location"); projectionFields.add("sd.parameters"); projectionFields.add("createTime"); projectionFields.add("sd"); PartitionProjectionEvaluator projectionEvaluator = new PartitionProjectionEvaluator(mockPm, fieldNameToColumnName, projectionFields, false, false, null, null); Set<PartitionFieldNode> roots = projectionEvaluator.getRoots(); Assert.assertFalse("sd.location should not contained since it is already included in sd", roots.contains(new PartitionFieldNode("sd.location"))); Assert.assertFalse("sd.parameters should not contained since it is already included in sd", roots.contains(new PartitionFieldNode("sd.parameters"))); }