MapReduceUtils { public static boolean partSpecInclusive(TableInfo desc, TableInfo existing) { if (!desc.getProjectName().equalsIgnoreCase(existing.getProjectName()) || !desc.getTableName() .equalsIgnoreCase(existing.getTableName())) { return false; } if (desc.getPartitionSpec() != null) { for (String key : desc.getPartSpec().keySet()) { if (!desc.getPartSpec().get(key).equals(existing.getPartSpec().get(key))) { return false; } } } return true; }  static void runMapper(Class<Mapper> clz, Mapper.TaskContext ctx); static void runReducer(Class<Reducer> clz, Reducer.TaskContext ctx); static boolean partSpecInclusive(TableInfo desc, TableInfo existing);  }
@Test public void testPartSpecInclusive() { Assert.assertTrue(MapReduceUtils.partSpecInclusive( TableInfo.builder().projectName("foo").tableName("bar").build(), TableInfo.builder().projectName("foo").tableName("bar").build())); Assert.assertTrue(MapReduceUtils.partSpecInclusive( TableInfo.builder().projectName("foo").tableName("bar").build(), TableInfo.builder().projectName("foo").tableName("bar").partSpec("foo=1").build())); Assert.assertTrue(MapReduceUtils.partSpecInclusive( TableInfo.builder().projectName("foo").tableName("bar").partSpec("foo=1").build(), TableInfo.builder().projectName("foo").tableName("bar").partSpec("foo=1/bar=2").build())); Assert.assertFalse(MapReduceUtils.partSpecInclusive( TableInfo.builder().projectName("foo").tableName("bar").partSpec("foo=1/bar=2").build(), TableInfo.builder().projectName("foo").tableName("bar").partSpec("foo=1").build())); }