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

jmclean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new bd41384a6c [#7520] fix: Deduplicate supportPartitions() call (#7539)
bd41384a6c is described below

commit bd41384a6c1b92a96a6aefb6c54c0ffb748a2bff
Author: kitoha <[email protected]>
AuthorDate: Wed Jul 2 16:11:45 2025 +0900

    [#7520] fix: Deduplicate supportPartitions() call (#7539)
    
    ### What changes were proposed in this pull request?
    
    This PR removes the redundant invocation of `table.supportPartitions()`
    in `CatalogWrapper#doWithPartitionOps`.
    Now, the method is called once and its result is cached in a local
    variable.
    
    ### Why are the changes needed?
    
    Calling `table.supportPartitions()` twice results in unnecessary
    repeated look-ups.
    Caching the result improves code readability and performance.
    
    Fix:  #7520
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    No behavior change is expected.
---
 core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java 
b/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
index 336efc1477..17c0e97701 100644
--- a/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
+++ b/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java
@@ -218,9 +218,10 @@ public class CatalogManager implements CatalogDispatcher, 
Closeable {
             Preconditions.checkArgument(
                 asTables() != null, "Catalog does not support table 
operations");
             Table table = asTables().loadTable(tableIdent);
+            SupportsPartitions partitionOps = table.supportPartitions();
             Preconditions.checkArgument(
-                table.supportPartitions() != null, "Table does not support 
partition operations");
-            return fn.apply(table.supportPartitions());
+                partitionOps != null, "Table does not support partition 
operations");
+            return fn.apply(partitionOps);
           });
     }
 

Reply via email to