@Test public void addPartition() throws Exception { doReturn(addedPartition).when(metaStoreClient).add_partition(any()); doReturn(URI.create("resolved/location")).when(locationResolver).resolveLocation(LOCATION, false); doReturn(Instant.ofEpochSecond(1526462225L)).when(clock).instant(); Partition result = underTest.addPartition(TABLE, PARTITION_VALUES, LOCATION).get(); ArgumentCaptor<Partition> captor = ArgumentCaptor.forClass(Partition.class); verify(metaStoreClient).add_partition(captor.capture()); Partition partition = captor.getValue(); assertThat(partition.getParameters().get("data-highway.version"), is(DataHighwayVersion.VERSION)); assertThat(partition.getParameters().get("data-highway.last-revision"), is("2018-05-16T09:17:05Z")); assertThat(partition.getSd().getLocation(), is("resolved/location")); assertThat(result, is(addedPartition)); }
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);  }