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

yuqi4733 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 837e2b19f2 [#10496] improvement(lance): Clean up redundant code in 
GravitinoLanceTableOperations#createTable (#10497)
837e2b19f2 is described below

commit 837e2b19f2c42e42eab6bb760647e7d32c1b5752
Author: Yuw1 <[email protected]>
AuthorDate: Tue Mar 24 18:34:35 2026 +0800

    [#10496] improvement(lance): Clean up redundant code in 
GravitinoLanceTableOperations#createTable (#10497)
    
    <!--
    1. Title: [#<issue>] <type>(<scope>): <subject>
       Examples:
         - "[#123] feat(operator): Support xxx"
         - "[#233] fix: Check null before access result in xxx"
         - "[MINOR] refactor: Fix typo in variable name"
         - "[MINOR] docs: Fix typo in README"
         - "[#255] test: Fix flaky test NameOfTheTest"
       Reference: https://www.conventionalcommits.org/en/v1.0.0/
    2. If the PR is unfinished, please mark this PR as draft.
    -->
    
    ### What changes were proposed in this pull request?
    This PR refactors the response construction logic in
    `GravitinoLanceTableOperations#createTable`:
    1. **Removed redundant setters**: Deleted the initial
    `response.setLocation(tableLocation)` and the first
    `response.setProperties(t.properties())` as they were immediately
    overwritten.
    2. **Extracted local variable**: Stored `t.properties()` in a local
    variable to ensure a single source of truth and avoid multiple redundant
    method calls.
    
    ### Why are the changes needed?
    The original code contained "dead store" assignments where values were
    set and then immediately overwritten. This cleanup improves code
    readability and eliminates unnecessary method calls.
    
    Fix: #10496
    
    ### Does this PR introduce any user-facing change?
    No.
    
    ### How was this patch tested?
    Passed `./gradlew :lance:lance-common:build` to ensure the project
    compiles and no regressions were introduced.
---
 .../common/ops/gravitino/GravitinoLanceTableOperations.java | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git 
a/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java
 
b/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java
index b9e36ecb47..b3039a656d 100644
--- 
a/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java
+++ 
b/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java
@@ -158,19 +158,16 @@ public class GravitinoLanceTableOperations implements 
LanceTableOperations {
             .asTableCatalog()
             .createTable(
                 tableIdentifier, columns.toArray(new Column[0]), null, 
createTableProperties);
+    Map<String, String> properties = t.properties();
 
     CreateTableResponse response = new CreateTableResponse();
-    response.setProperties(t.properties());
-    response.setLocation(tableLocation);
     // Extract storage options from table properties. All storage options 
stores in table
     // properties.
-    
response.setStorageOptions(LancePropertiesUtils.getLanceStorageOptions(t.properties()));
+    
response.setStorageOptions(LancePropertiesUtils.getLanceStorageOptions(properties));
     response.setVersion(
-        Optional.ofNullable(t.properties().get(LANCE_TABLE_VERSION))
-            .map(Long::valueOf)
-            .orElse(null));
-    response.setLocation(t.properties().get(LANCE_LOCATION));
-    response.setProperties(t.properties());
+        
Optional.ofNullable(properties.get(LANCE_TABLE_VERSION)).map(Long::valueOf).orElse(null));
+    response.setLocation(properties.get(LANCE_LOCATION));
+    response.setProperties(properties);
     return response;
   }
 

Reply via email to