@Test public void addPartition_shouldIgnoreAlreadyExistsException() throws Exception { doThrow(AlreadyExistsException.class).when(metaStoreClient).add_partition(any()); doReturn(URI.create("resolved/location")).when(locationResolver).resolveLocation(LOCATION, false); doReturn(Instant.ofEpochSecond(1526462225L)).when(clock).instant(); Optional<Partition> result = underTest.addPartition(TABLE, PARTITION_VALUES, LOCATION); assertThat(result.isPresent(), is(false)); }
public Optional<Partition> addPartition( String tableName, List<String> partitionValues, String location, Map<String, String> parameters) throws MetaStoreException { try { URI resolvedLocation = locationResolver.resolveLocation(location, false); Partition partition = newHivePartition(tableName, partitionValues, resolvedLocation.toString(), parameters); partition = metaStoreClient.add_partition(partition); return Optional.of(partition); } catch (AlreadyExistsException e) { return Optional.empty(); } catch (TException e) { throw new MetaStoreException(e); } }
HivePartitionManager { public Optional<Partition> addPartition( String tableName, List<String> partitionValues, String location, Map<String, String> parameters) throws MetaStoreException { try { URI resolvedLocation = locationResolver.resolveLocation(location, false); Partition partition = newHivePartition(tableName, partitionValues, resolvedLocation.toString(), parameters); partition = metaStoreClient.add_partition(partition); return Optional.of(partition); } catch (AlreadyExistsException e) { return Optional.empty(); } catch (TException e) { throw new MetaStoreException(e); } } }
HivePartitionManager { public Optional<Partition> addPartition( String tableName, List<String> partitionValues, String location, Map<String, String> parameters) throws MetaStoreException { try { URI resolvedLocation = locationResolver.resolveLocation(location, false); Partition partition = newHivePartition(tableName, partitionValues, resolvedLocation.toString(), parameters); partition = metaStoreClient.add_partition(partition); return Optional.of(partition); } catch (AlreadyExistsException e) { return Optional.empty(); } catch (TException e) { throw new MetaStoreException(e); } }  }
HivePartitionManager { public Optional<Partition> addPartition( String tableName, List<String> partitionValues, String location, Map<String, String> parameters) throws MetaStoreException { try { URI resolvedLocation = locationResolver.resolveLocation(location, false); Partition partition = newHivePartition(tableName, partitionValues, resolvedLocation.toString(), parameters); partition = metaStoreClient.add_partition(partition); return Optional.of(partition); } catch (AlreadyExistsException e) { return Optional.empty(); } catch (TException e) { throw new MetaStoreException(e); } }  Optional<Partition> addPartition(
      String tableName,
      List<String> partitionValues,
      String location,
      Map<String, String> parameters); Optional<Partition> addPartition(String tableName, List<String> partitionValues, String location); void dropPartition(String tableName, List<String> partitionValues); }
HivePartitionManager { public Optional<Partition> addPartition( String tableName, List<String> partitionValues, String location, Map<String, String> parameters) throws MetaStoreException { try { URI resolvedLocation = locationResolver.resolveLocation(location, false); Partition partition = newHivePartition(tableName, partitionValues, resolvedLocation.toString(), parameters); partition = metaStoreClient.add_partition(partition); return Optional.of(partition); } catch (AlreadyExistsException e) { return Optional.empty(); } catch (TException e) { throw new MetaStoreException(e); } }  Optional<Partition> addPartition(
      String tableName,
      List<String> partitionValues,
      String location,
      Map<String, String> parameters); Optional<Partition> addPartition(String tableName, List<String> partitionValues, String location); void dropPartition(String tableName, List<String> partitionValues);  }