class CleanPartitionFunction implements Function<PartitionAndMetadata, PartitionAndMetadata> {

  @Override
  public PartitionAndMetadata apply(PartitionAndMetadata partitionAndMetadata) {
    if (partitionAndMetadata == null) {
      return null;
    }

    Partition partitionCopy = partitionAndMetadata.getPartition().deepCopy();
    for (CircusTrainTableParameter p : CircusTrainTableParameter.values()) {
      partitionCopy.getParameters().remove(p.parameterName());
    }
    for (ExcludedHiveParameter p : ExcludedHiveParameter.values()) {
      partitionCopy.getParameters().remove(p.parameterName());
    }
    return new PartitionAndMetadata(partitionAndMetadata.getSourceTable(), partitionAndMetadata.getSourceLocation(),
        partitionCopy);
  }

}