Skip to content

Commit

Permalink
[core] Introduce refreshPartitions interface to CachingCatalog (#4455)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdzs0612 authored Nov 5, 2024
1 parent 5df7eed commit 33341fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ public List<PartitionEntry> listPartitions(Identifier identifier)
return result;
}

public void refreshPartitions(Identifier identifier) throws TableNotExistException {
if (partitionCache != null) {
List<PartitionEntry> result = wrapped.listPartitions(identifier);
partitionCache.put(identifier, result);
}
}

@Override
public void dropPartition(Identifier identifier, Map<String, String> partitions)
throws TableNotExistException, PartitionNotExistException {
Expand All @@ -289,6 +296,9 @@ public void onRemoval(Identifier identifier, Table table, @NonNull RemovalCause
public void invalidateTable(Identifier identifier) {
tableCache.invalidate(identifier);
tryInvalidateSysTables(identifier);
if (partitionCache != null) {
partitionCache.invalidate(identifier);
}
}

private void tryInvalidateSysTables(Identifier identifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ public void testPartitionCache() throws Exception {
catalog.createTable(tableIdent, schema, false);
List<PartitionEntry> partitionEntryList = catalog.listPartitions(tableIdent);
assertThat(catalog.partitionCache().asMap()).containsKey(tableIdent);
catalog.invalidateTable(tableIdent);
catalog.refreshPartitions(tableIdent);
assertThat(catalog.partitionCache().asMap()).containsKey(tableIdent);
List<PartitionEntry> partitionEntryListFromCache =
catalog.partitionCache().getIfPresent(tableIdent);
assertThat(partitionEntryListFromCache).isNotNull();
Expand Down

0 comments on commit 33341fa

Please sign in to comment.