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

JingsongLi 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 23fbf740dc [rest] Remove renameBranch REST endpoint (#8023)
23fbf740dc is described below

commit 23fbf740dca4b11c42fc6a6fa70aef055d16155c
Author: kevin <[email protected]>
AuthorDate: Sun May 31 21:30:44 2026 +0800

    [rest] Remove renameBranch REST endpoint (#8023)
    
    The server-side implementation of `renameBranch` ultimately relies on
    the underlying object store's rename (e.g. OSS), which is **not atomic**.
    While the rename is in progress, concurrent writes to the source branch can 
be
    silently lost, and there is currently no reliable way for the server to 
fence those writes during the operation.
    
    Because of this consistency risk, we'd rather not offer `renameBranch`
    over the REST catalog at all than offer it with a known data-loss window.
    This PR retires only the REST surface — the `Catalog` interface and the
    non-REST implementations (file-system branch manager, Spark/Flink 
procedures,
    etc.) are intentionally left untouched, so users on those code paths are 
not affected.
---
 .../main/java/org/apache/paimon/rest/RESTApi.java  | 22 -----------
 .../java/org/apache/paimon/rest/ResourcePaths.java | 13 ------
 .../paimon/rest/requests/RenameBranchRequest.java  | 46 ----------------------
 .../java/org/apache/paimon/rest/RESTCatalog.java   | 10 +----
 .../org/apache/paimon/rest/RESTCatalogServer.java  | 27 +------------
 .../org/apache/paimon/rest/RESTCatalogTest.java    | 20 +---------
 6 files changed, 3 insertions(+), 135 deletions(-)

diff --git a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java 
b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
index 7433a30388..263c4e2c06 100644
--- a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
+++ b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
@@ -49,7 +49,6 @@ import org.apache.paimon.rest.requests.ForwardBranchRequest;
 import org.apache.paimon.rest.requests.ListPartitionsByNamesRequest;
 import org.apache.paimon.rest.requests.MarkDonePartitionsRequest;
 import org.apache.paimon.rest.requests.RegisterTableRequest;
-import org.apache.paimon.rest.requests.RenameBranchRequest;
 import org.apache.paimon.rest.requests.RenameTableRequest;
 import org.apache.paimon.rest.requests.ReplaceTableRequest;
 import org.apache.paimon.rest.requests.ResetConsumerRequest;
@@ -985,27 +984,6 @@ public class RESTApi {
                 restAuthFunction);
     }
 
-    /**
-     * Rename branch for table.
-     *
-     * @param identifier database name and table name.
-     * @param fromBranch source branch name
-     * @param toBranch target branch name
-     * @throws NoSuchResourceException Exception thrown on HTTP 404 means the 
branch not exists
-     * @throws AlreadyExistsException Exception thrown on HTTP 409 means the 
target branch already
-     *     exists
-     * @throws ForbiddenException Exception thrown on HTTP 403 means don't 
have the permission for
-     *     this table
-     */
-    public void renameBranch(Identifier identifier, String fromBranch, String 
toBranch) {
-        RenameBranchRequest request = new RenameBranchRequest(toBranch);
-        client.post(
-                resourcePaths.renameBranch(
-                        identifier.getDatabaseName(), 
identifier.getObjectName(), fromBranch),
-                request,
-                restAuthFunction);
-    }
-
     /**
      * Forward branch for table.
      *
diff --git a/paimon-api/src/main/java/org/apache/paimon/rest/ResourcePaths.java 
b/paimon-api/src/main/java/org/apache/paimon/rest/ResourcePaths.java
index 66a1653232..28f79d0409 100644
--- a/paimon-api/src/main/java/org/apache/paimon/rest/ResourcePaths.java
+++ b/paimon-api/src/main/java/org/apache/paimon/rest/ResourcePaths.java
@@ -273,19 +273,6 @@ public class ResourcePaths {
                 "forward");
     }
 
-    public String renameBranch(String databaseName, String tableName, String 
branch) {
-        return SLASH.join(
-                V1,
-                prefix,
-                DATABASES,
-                encodeString(databaseName),
-                TABLES,
-                encodeString(tableName),
-                BRANCHES,
-                encodeString(branch),
-                "rename");
-    }
-
     public String tags(String databaseName, String objectName) {
         return SLASH.join(
                 V1,
diff --git 
a/paimon-api/src/main/java/org/apache/paimon/rest/requests/RenameBranchRequest.java
 
b/paimon-api/src/main/java/org/apache/paimon/rest/requests/RenameBranchRequest.java
deleted file mode 100644
index 63cf0011fa..0000000000
--- 
a/paimon-api/src/main/java/org/apache/paimon/rest/requests/RenameBranchRequest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.paimon.rest.requests;
-
-import org.apache.paimon.rest.RESTRequest;
-
-import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
-import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonGetter;
-import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
-
-/** Request for renaming branch. */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class RenameBranchRequest implements RESTRequest {
-
-    private static final String FIELD_TO_BRANCH = "toBranch";
-
-    @JsonProperty(FIELD_TO_BRANCH)
-    private final String toBranch;
-
-    @JsonCreator
-    public RenameBranchRequest(@JsonProperty(FIELD_TO_BRANCH) String toBranch) 
{
-        this.toBranch = toBranch;
-    }
-
-    @JsonGetter(FIELD_TO_BRANCH)
-    public String toBranch() {
-        return toBranch;
-    }
-}
diff --git a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
index 7e2f6cfd27..9d76cfdf4f 100644
--- a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
@@ -761,15 +761,7 @@ public class RESTCatalog implements Catalog {
     @Override
     public void renameBranch(Identifier identifier, String fromBranch, String 
toBranch)
             throws BranchNotExistException, BranchAlreadyExistException {
-        try {
-            api.renameBranch(identifier, fromBranch, toBranch);
-        } catch (NoSuchResourceException e) {
-            throw new BranchNotExistException(identifier, fromBranch, e);
-        } catch (AlreadyExistsException e) {
-            throw new BranchAlreadyExistException(identifier, toBranch, e);
-        } catch (ForbiddenException e) {
-            throw new TableNoPermissionException(identifier, e);
-        }
+        throw new UnsupportedOperationException();
     }
 
     @Override
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
index 74e4f4e465..af5d94e3f6 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
@@ -61,7 +61,6 @@ import org.apache.paimon.rest.requests.CreateTagRequest;
 import org.apache.paimon.rest.requests.CreateViewRequest;
 import org.apache.paimon.rest.requests.ListPartitionsByNamesRequest;
 import org.apache.paimon.rest.requests.MarkDonePartitionsRequest;
-import org.apache.paimon.rest.requests.RenameBranchRequest;
 import org.apache.paimon.rest.requests.RenameTableRequest;
 import org.apache.paimon.rest.requests.ReplaceTableRequest;
 import org.apache.paimon.rest.requests.ResetConsumerRequest;
@@ -1888,31 +1887,7 @@ public class RESTCatalogServer {
                 case "POST":
                     if (resources.length == 6) {
                         branch = RESTUtil.decodeString(resources[4]);
-                        if ("rename".equals(resources[5])) {
-                            // Rename branch: /branches/{branch}/rename
-                            RenameBranchRequest requestBody =
-                                    RESTApi.fromJson(data, 
RenameBranchRequest.class);
-                            String toBranch = requestBody.toBranch();
-                            table.renameBranch(branch, toBranch);
-                            // Update store for renamed branch
-                            Identifier fromBranchIdentifier =
-                                    new Identifier(
-                                            identifier.getDatabaseName(),
-                                            identifier.getTableName(),
-                                            branch);
-                            Identifier toBranchIdentifier =
-                                    new Identifier(
-                                            identifier.getDatabaseName(),
-                                            identifier.getTableName(),
-                                            toBranch);
-                            tableLatestSnapshotStore.put(
-                                    toBranchIdentifier.getFullName(),
-                                    tableLatestSnapshotStore.get(
-                                            
fromBranchIdentifier.getFullName()));
-                            tableMetadataStore.put(
-                                    toBranchIdentifier.getFullName(),
-                                    
tableMetadataStore.get(fromBranchIdentifier.getFullName()));
-                        } else if ("forward".equals(resources[5])) {
+                        if ("forward".equals(resources[5])) {
                             // Fast forward branch
                             branchManager.fastForward(branch);
                             branchIdentifier =
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
index 8cefa2ec7b..6ff873aed1 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
@@ -2161,25 +2161,7 @@ public abstract class RESTCatalogTest extends 
CatalogTestBase {
                 () -> restCatalog.createBranch(identifier, "my_branch", null));
         
assertThat(restCatalog.listBranches(identifier)).containsOnly("my_branch");
 
-        // Test rename branch
-        restCatalog.renameBranch(identifier, "my_branch", "renamed_branch");
-        
assertThat(restCatalog.listBranches(identifier)).containsOnly("renamed_branch");
-        assertThat(restCatalog.getTable(new Identifier(databaseName, "table", 
"renamed_branch")))
-                .isNotNull();
-
-        // Test rename to existing branch should fail
-        restCatalog.createBranch(identifier, "another_branch", null);
-        assertThrows(
-                Catalog.BranchAlreadyExistException.class,
-                () -> restCatalog.renameBranch(identifier, "renamed_branch", 
"another_branch"));
-
-        // Test rename non-existent branch should fail
-        assertThrows(
-                Catalog.BranchNotExistException.class,
-                () -> restCatalog.renameBranch(identifier, 
"non_existent_branch", "new_branch"));
-
-        restCatalog.dropBranch(identifier, "renamed_branch");
-        restCatalog.dropBranch(identifier, "another_branch");
+        restCatalog.dropBranch(identifier, "my_branch");
 
         assertThrows(
                 Catalog.BranchNotExistException.class,

Reply via email to