Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@ public void retry(ManifestCommittable committable) {
addPartitions(partitions);
}

private void addPartition(BinaryRow partition) {
try {
boolean added = cache.get(partition, () -> false);
if (added) {
return;
}

client.addPartition(partition);
cache.put(partition, true);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private void addPartitions(Set<BinaryRow> partitions) {
try {
List<BinaryRow> newPartitions = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
import org.apache.hadoop.hive.metastore.api.Partition;
import org.apache.hadoop.hive.metastore.api.PartitionEventType;
Expand Down Expand Up @@ -92,21 +93,15 @@ public void addPartitions(List<BinaryRow> partitions) throws Exception {

@Override
public void addPartition(LinkedHashMap<String, String> partitionSpec) throws Exception {
List<String> partitionValues = new ArrayList<>(partitionSpec.values());
try {
clients.execute(
client ->
client.getPartition(
identifier.getDatabaseName(),
identifier.getTableName(),
partitionValues));
// do nothing if the partition already exists
} catch (NoSuchObjectException e) {
// partition not found, create new partition
Partition hivePartition =
toHivePartition(partitionSpec, (int) (System.currentTimeMillis() / 1000));
clients.execute(client -> client.add_partition(hivePartition));
}
Partition hivePartition =
toHivePartition(partitionSpec, (int) (System.currentTimeMillis() / 1000));
clients.execute(
client -> {
try {
client.add_partition(hivePartition);
} catch (AlreadyExistsException ignore) {
}
});
}

@Override
Expand Down
Loading