Skip to content

Commit

Permalink
[core] Tolerate the NoSuchObjectException when report the partition s…
Browse files Browse the repository at this point in the history
…tatistic (#4708)
  • Loading branch information
Aitozi authored Dec 15, 2024
1 parent d61f3d2 commit 72e7150
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ default void addPartitionsSpec(List<LinkedHashMap<String, String>> partitionSpec
default void alterPartition(
LinkedHashMap<String, String> partitionSpec,
Map<String, String> parameters,
long modifyTime)
long modifyTime,
boolean ignoreIfNotExist)
throws Exception {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void report(String partition, long modifyTime) throws Exception {
statistic.put(HIVE_LAST_UPDATE_TIME_PROP, String.valueOf(modifyTime / 1000));

LOG.info("alter partition {} with statistic {}.", partitionSpec, statistic);
metastoreClient.alterPartition(partitionSpec, statistic, modifyTime);
metastoreClient.alterPartition(partitionSpec, statistic, modifyTime, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public void markDone(LinkedHashMap<String, String> partitionSpec)
public void alterPartition(
LinkedHashMap<String, String> partitionSpec,
Map<String, String> parameters,
long modifyTime)
long modifyTime,
boolean ignoreIfNotExist)
throws Exception {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public void markDone(LinkedHashMap<String, String> partitionSpec)
public void alterPartition(
LinkedHashMap<String, String> partitionSpec,
Map<String, String> parameters,
long modifyTime)
long modifyTime,
boolean ignoreIfNotExist)
throws Exception {
partitionParams.put(
PartitionPathUtils.generatePartitionPath(partitionSpec),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,28 @@ public void addPartitionsSpec(List<LinkedHashMap<String, String>> partitionSpecs
public void alterPartition(
LinkedHashMap<String, String> partitionSpec,
Map<String, String> parameters,
long modifyTime)
long modifyTime,
boolean ignoreIfNotExist)
throws Exception {
List<String> partitionValues = new ArrayList<>(partitionSpec.values());
int currentTime = (int) (modifyTime / 1000);
Partition hivePartition =
clients.run(
client ->
client.getPartition(
identifier.getDatabaseName(),
identifier.getObjectName(),
partitionValues));
Partition hivePartition;
try {
hivePartition =
clients.run(
client ->
client.getPartition(
identifier.getDatabaseName(),
identifier.getObjectName(),
partitionValues));
} catch (NoSuchObjectException e) {
if (ignoreIfNotExist) {
return;
} else {
throw e;
}
}

hivePartition.setValues(partitionValues);
hivePartition.setLastAccessTime(currentTime);
hivePartition.getParameters().putAll(parameters);
Expand Down

0 comments on commit 72e7150

Please sign in to comment.