Skip to content

Commit bd41384

Browse files
authored
[#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.
1 parent 8d20c48 commit bd41384

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ public <R> R doWithPartitionOps(
218218
Preconditions.checkArgument(
219219
asTables() != null, "Catalog does not support table operations");
220220
Table table = asTables().loadTable(tableIdent);
221+
SupportsPartitions partitionOps = table.supportPartitions();
221222
Preconditions.checkArgument(
222-
table.supportPartitions() != null, "Table does not support partition operations");
223-
return fn.apply(table.supportPartitions());
223+
partitionOps != null, "Table does not support partition operations");
224+
return fn.apply(partitionOps);
224225
});
225226
}
226227

0 commit comments

Comments
 (0)