This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 33341faa9 [core] Introduce refreshPartitions interface to 
CachingCatalog (#4455)
33341faa9 is described below

commit 33341faa9ffe14625c8109a63f4a43bf8d06fb2c
Author: Jiao Mingye <[email protected]>
AuthorDate: Tue Nov 5 16:40:45 2024 +0800

    [core] Introduce refreshPartitions interface to CachingCatalog (#4455)
---
 .../main/java/org/apache/paimon/catalog/CachingCatalog.java    | 10 ++++++++++
 .../java/org/apache/paimon/catalog/CachingCatalogTest.java     |  3 +++
 2 files changed, 13 insertions(+)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
index b1f683e40..03edbaab7 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
@@ -266,6 +266,13 @@ public class CachingCatalog extends DelegateCatalog {
         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 {
@@ -289,6 +296,9 @@ public class CachingCatalog extends DelegateCatalog {
     public void invalidateTable(Identifier identifier) {
         tableCache.invalidate(identifier);
         tryInvalidateSysTables(identifier);
+        if (partitionCache != null) {
+            partitionCache.invalidate(identifier);
+        }
     }
 
     private void tryInvalidateSysTables(Identifier identifier) {
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java 
b/paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java
index 0cdd9486c..65ed5ce0b 100644
--- 
a/paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java
+++ 
b/paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java
@@ -243,6 +243,9 @@ class CachingCatalogTest extends CatalogTestBase {
         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();

Reply via email to