Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
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;
Expand Down Expand Up @@ -985,27 +984,6 @@ public void dropBranch(Identifier identifier, String branch) {
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.
*
Expand Down
13 changes: 0 additions & 13 deletions paimon-api/src/main/java/org/apache/paimon/rest/ResourcePaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,6 @@ public String forwardBranch(String databaseName, String tableName, String branch
"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,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -761,15 +761,7 @@ public void dropBranch(Identifier identifier, String branch) throws BranchNotExi
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
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;
Expand Down Expand Up @@ -1888,31 +1887,7 @@ private MockResponse branchApiHandle(
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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2161,25 +2161,7 @@ void testBranches() throws Exception {
() -> 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,
Expand Down