Skip to content

Commit

Permalink
[core] Remove replace branch to reduce IO (#3618)
Browse files Browse the repository at this point in the history
* [core] Remove replace branch to reduce IO
  • Loading branch information
JingsongLi authored Jun 27, 2024
1 parent cb6f06e commit 368cfd4
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 540 deletions.
14 changes: 0 additions & 14 deletions docs/content/flink/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,5 @@ All available procedures are listed below.
CALL sys.merge_branch('default.T', 'branch1')
</td>
</tr>
<tr>
<td>replace_branch</td>
<td>
CALL [catalog.]sys.replace_branch('identifier', 'branchName')
</td>
<td>
To replace main branch with specified branch. Arguments:
<li>identifier: the target table identifier. Cannot be empty.</li>
<li>branchName: name of the branch to be replaced.</li>
</td>
<td>
CALL sys.replace_branch('default.T', 'branch1')
</td>
</tr>
</tbody>
</table>
21 changes: 0 additions & 21 deletions docs/content/maintenance/manage-branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,3 @@ CALL sys.merge_branch('default.T', 'branch1');
{{< /tab >}}

{{< /tabs >}}

## Replace Branch

Replacing main branch with custom branch will copy the snapshots, tags and schemas which should be copied from the main branch to target branch, and then the custom branch will be the new 'main' branch.

Suppose there is a job read and write the specified branch, by replacing main branch with the created branch, we don't need to do
anything with this job, for the new branch is totally complete now, and the 'main' branch is pointed to the new branch now.

We cannot merge branch to main here because the new job will still read and write the specified branch which will be completely independent of main.

{{< tabs "replace-branch" >}}

{{< tab "Flink" >}}

```sql
CALL sys.replace_branch('default.T', 'branch1');
```

{{< /tab >}}

{{< /tabs >}}
11 changes: 0 additions & 11 deletions docs/content/spark/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,6 @@ This section introduce all available spark procedures about paimon.
CALL sys.merge_branch(table => 'test_db.T', branch => 'test_branch')
</td>
</tr>
<tr>
<td>replace_branch</td>
<td>
To replace main branch with specified branch. Arguments:
<li>table: the target table identifier. Cannot be empty.</li>
<li>branch: name of the branch to be replaced.</li>
</td>
<td>
CALL sys.replace_branch(table => 'test_db.T', branch => 'test_branch')
</td>
</tr>
<tr>
<td>reset_consumer</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@ public void mergeBranch(String branchName) {
wrapped.mergeBranch(branchName);
}

@Override
public void replaceBranch(String fromBranch) {
privilegeChecker.assertCanInsert(identifier);
wrapped.replaceBranch(fromBranch);
}

@Override
public ExpireSnapshots newExpireSnapshots() {
privilegeChecker.assertCanInsert(identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import static org.apache.paimon.catalog.AbstractCatalog.DB_SUFFIX;
import static org.apache.paimon.catalog.Identifier.UNKNOWN_DATABASE;
import static org.apache.paimon.utils.BranchManager.DEFAULT_MAIN_BRANCH;
import static org.apache.paimon.utils.BranchManager.getBranchPath;
import static org.apache.paimon.utils.BranchManager.branchPath;
import static org.apache.paimon.utils.FileUtils.listVersionedFiles;
import static org.apache.paimon.utils.Preconditions.checkState;

Expand Down Expand Up @@ -499,13 +499,12 @@ public static TableSchema fromPath(FileIO fileIO, Path path) {
}

public Path schemaDirectory() {
return new Path(getBranchPath(fileIO, tableRoot, branch) + "/schema");
return new Path(branchPath(tableRoot, branch) + "/schema");
}

@VisibleForTesting
public Path toSchemaPath(long schemaId) {
return new Path(
getBranchPath(fileIO, tableRoot, branch) + "/schema/" + SCHEMA_PREFIX + schemaId);
return new Path(branchPath(tableRoot, branch) + "/schema/" + SCHEMA_PREFIX + schemaId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,6 @@ public void mergeBranch(String branchName) {
branchManager().mergeBranch(branchName);
}

@Override
public void replaceBranch(String fromBranch) {
branchManager().replaceBranch(fromBranch);
}

@Override
public void rollbackTo(String tagName) {
TagManager tagManager = tagManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,6 @@ default void mergeBranch(String branchName) {
this.getClass().getSimpleName()));
}

@Override
default void replaceBranch(String fromBranch) {
throw new UnsupportedOperationException(
String.format(
"Readonly Table %s does not support replaceBranch.",
this.getClass().getSimpleName()));
}

@Override
default ExpireSnapshots newExpireSnapshots() {
throw new UnsupportedOperationException(
Expand Down
3 changes: 0 additions & 3 deletions paimon-core/src/main/java/org/apache/paimon/table/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ public interface Table extends Serializable {
@Experimental
void mergeBranch(String branchName);

@Experimental
void replaceBranch(String fromBranch);

/** Manually expire snapshots, parameters can be controlled independently of table options. */
@Experimental
ExpireSnapshots newExpireSnapshots();
Expand Down
Loading

0 comments on commit 368cfd4

Please sign in to comment.