From 312ce5f35aebf76a0056610ef962cdc81b60349d Mon Sep 17 00:00:00 2001 From: HunterXHunter Date: Sun, 11 Aug 2024 22:01:23 +0800 Subject: [PATCH] [core] Remove the feature that creates branches from snapshots. (#3934) --- docs/content/flink/procedures.md | 6 +- docs/content/maintenance/manage-branches.md | 4 - docs/content/spark/procedures.md | 2 - .../privilege/PrivilegedFileStoreTable.java | 6 -- .../paimon/table/AbstractFileStoreTable.java | 5 - .../paimon/table/DelegatedFileStoreTable.java | 5 - .../apache/paimon/table/ReadonlyTable.java | 8 -- .../java/org/apache/paimon/table/Table.java | 4 - .../apache/paimon/utils/BranchManager.java | 34 ------- .../flink/action/CreateBranchAction.java | 8 +- .../action/CreateBranchActionFactory.java | 11 +-- .../procedure/CreateBranchProcedure.java | 14 +-- .../apache/paimon/flink/BranchSqlITCase.java | 57 ++++-------- .../flink/action/BranchActionITCase.java | 92 ------------------- .../flink/action/ConsumerActionITCase.java | 3 +- .../procedure/CreateBranchProcedure.java | 7 +- .../CreateAndDeleteBranchProcedureTest.scala | 29 ------ 17 files changed, 29 insertions(+), 266 deletions(-) diff --git a/docs/content/flink/procedures.md b/docs/content/flink/procedures.md index 3fae9b40512f..6209791b876a 100644 --- a/docs/content/flink/procedures.md +++ b/docs/content/flink/procedures.md @@ -308,22 +308,18 @@ All available procedures are listed below. create_branch - -- based on the specified snapshot
- CALL [catalog.]sys.create_branch('identifier', 'branchName', snapshotId)
-- based on the specified tag
CALL [catalog.]sys.create_branch('identifier', 'branchName', 'tagName') -- create empty branch
CALL [catalog.]sys.create_branch('identifier', 'branchName') - To create a branch based on given snapshot / tag, or just create empty branch. Arguments: + To create a branch based on given tag, or just create empty branch. Arguments:
  • identifier: the target table identifier. Cannot be empty.
  • branchName: name of the new branch.
  • -
  • snapshotId (Long): id of the snapshot which the new branch is based on.
  • tagName: name of the tag which the new branch is based on.
  • - CALL sys.create_branch('default.T', 'branch1', 10)

    CALL sys.create_branch('default.T', 'branch1', 'tag1')

    CALL sys.create_branch('default.T', 'branch1')

    diff --git a/docs/content/maintenance/manage-branches.md b/docs/content/maintenance/manage-branches.md index 22ca9b8507d0..628caf1b54a2 100644 --- a/docs/content/maintenance/manage-branches.md +++ b/docs/content/maintenance/manage-branches.md @@ -46,9 +46,6 @@ Run the following sql: -- create branch named 'branch1' from tag 'tag1' CALL sys.create_branch('default.T', 'branch1', 'tag1'); --- create branch named 'branch1' from snapshot 1 -CALL sys.create_branch('default.T', 'branch1', 1); - -- create empty branch named 'branch1' CALL sys.create_branch('default.T', 'branch1'); ``` @@ -67,7 +64,6 @@ Run the following command: --table \ --branch_name \ [--tag_name ] \ - [--snapshot ] \ [--catalog_conf [--catalog_conf ...]] ``` {{< /tab >}} diff --git a/docs/content/spark/procedures.md b/docs/content/spark/procedures.md index c3b6292c71d6..9a53a79eecd9 100644 --- a/docs/content/spark/procedures.md +++ b/docs/content/spark/procedures.md @@ -171,12 +171,10 @@ This section introduce all available spark procedures about paimon.
  • table: the target table identifier. Cannot be empty.
  • branch: name of the branch to be merged.
  • tag: name of the new tag. Cannot be empty.
  • -
  • snapshot(Long): id of the snapshot which the new tag is based on.
  • CALL sys.create_branch(table => 'test_db.T', branch => 'test_branch')

    CALL sys.create_branch(table => 'test_db.T', branch => 'test_branch', tag => 'my_tag')

    - CALL sys.create_branch(table => 'test_db.T', branch => 'test_branch', snapshot => 10) diff --git a/paimon-core/src/main/java/org/apache/paimon/privilege/PrivilegedFileStoreTable.java b/paimon-core/src/main/java/org/apache/paimon/privilege/PrivilegedFileStoreTable.java index d590eb3708df..f412d4e5e06f 100644 --- a/paimon-core/src/main/java/org/apache/paimon/privilege/PrivilegedFileStoreTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/privilege/PrivilegedFileStoreTable.java @@ -145,12 +145,6 @@ public void createBranch(String branchName) { wrapped.createBranch(branchName); } - @Override - public void createBranch(String branchName, long snapshotId) { - privilegeChecker.assertCanInsert(identifier); - wrapped.createBranch(branchName, snapshotId); - } - @Override public void createBranch(String branchName, String tagName) { privilegeChecker.assertCanInsert(identifier); diff --git a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java index 6e3c79d4da81..04f5f6dd64a9 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java @@ -569,11 +569,6 @@ public void createBranch(String branchName) { branchManager().createBranch(branchName); } - @Override - public void createBranch(String branchName, long snapshotId) { - branchManager().createBranch(branchName, snapshotId); - } - @Override public void createBranch(String branchName, String tagName) { branchManager().createBranch(branchName, tagName); diff --git a/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java b/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java index 243ffb754c17..1ff64f2c1bc2 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/DelegatedFileStoreTable.java @@ -168,11 +168,6 @@ public void createBranch(String branchName) { wrapped.createBranch(branchName); } - @Override - public void createBranch(String branchName, long snapshotId) { - wrapped.createBranch(branchName, snapshotId); - } - @Override public void createBranch(String branchName, String tagName) { wrapped.createBranch(branchName, tagName); diff --git a/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java b/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java index b9eeba398400..4854f983d9af 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/ReadonlyTable.java @@ -176,14 +176,6 @@ default void createBranch(String branchName) { this.getClass().getSimpleName())); } - @Override - default void createBranch(String branchName, long snapshotId) { - throw new UnsupportedOperationException( - String.format( - "Readonly Table %s does not support createBranch with snapshotId.", - this.getClass().getSimpleName())); - } - @Override default void createBranch(String branchName, String tagName) { throw new UnsupportedOperationException( diff --git a/paimon-core/src/main/java/org/apache/paimon/table/Table.java b/paimon-core/src/main/java/org/apache/paimon/table/Table.java index 62207f882a77..55cf25aea331 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/Table.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/Table.java @@ -116,10 +116,6 @@ default void deleteTags(String tagNames) { @Experimental void createBranch(String branchName); - /** Create a branch from given snapshot. */ - @Experimental - void createBranch(String branchName, long snapshotId); - /** Create a branch from given tag. */ @Experimental void createBranch(String branchName, String tagName); diff --git a/paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java b/paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java index af598587c79f..0e905cd68fa3 100644 --- a/paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java +++ b/paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java @@ -125,40 +125,6 @@ branchName, branchPath(tablePath, branchName)), } } - public void createBranch(String branchName, long snapshotId) { - checkArgument( - !isMainBranch(branchName), - String.format( - "Branch name '%s' is the default branch and cannot be used.", - DEFAULT_MAIN_BRANCH)); - checkArgument(!StringUtils.isBlank(branchName), "Branch name '%s' is blank.", branchName); - checkArgument(!branchExists(branchName), "Branch name '%s' already exists.", branchName); - checkArgument( - !branchName.chars().allMatch(Character::isDigit), - "Branch name cannot be pure numeric string but is '%s'.", - branchName); - - Snapshot snapshot = snapshotManager.snapshot(snapshotId); - - try { - // Copy the corresponding snapshot and schema files into the branch directory - fileIO.copyFile( - snapshotManager.snapshotPath(snapshotId), - snapshotManager.copyWithBranch(branchName).snapshotPath(snapshot.id()), - true); - fileIO.copyFile( - schemaManager.toSchemaPath(snapshot.schemaId()), - schemaManager.copyWithBranch(branchName).toSchemaPath(snapshot.schemaId()), - true); - } catch (IOException e) { - throw new RuntimeException( - String.format( - "Exception occurs when create branch '%s' (directory in %s).", - branchName, branchPath(tablePath, branchName)), - e); - } - } - public void createBranch(String branchName, String tagName) { checkArgument( !isMainBranch(branchName), diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchAction.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchAction.java index 504f493ef6f9..aa8cc697ae36 100644 --- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchAction.java +++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchAction.java @@ -27,28 +27,22 @@ public class CreateBranchAction extends TableActionBase { private final String branchName; private final String tagName; - private final Long snapshotId; - public CreateBranchAction( String warehouse, String databaseName, String tableName, Map catalogConfig, String branchName, - String tagName, - Long snapshotId) { + String tagName) { super(warehouse, databaseName, tableName, catalogConfig); this.branchName = branchName; this.tagName = tagName; - this.snapshotId = snapshotId; } @Override public void run() throws Exception { if (!StringUtils.isBlank(tagName)) { table.createBranch(branchName, tagName); - } else if (snapshotId != null) { - table.createBranch(branchName, snapshotId); } else { table.createBranch(branchName); } diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchActionFactory.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchActionFactory.java index 2a093e16d8aa..d1071d0870ad 100644 --- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchActionFactory.java +++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/CreateBranchActionFactory.java @@ -30,7 +30,6 @@ public class CreateBranchActionFactory implements ActionFactory { private static final String TAG_NAME = "tag_name"; private static final String BRANCH_NAME = "branch_name"; - private static final String SNAPSHOT = "snapshot"; @Override public String identifier() { @@ -44,11 +43,6 @@ public Optional create(MultipleParameterToolAdapter params) { Tuple3 tablePath = getTablePath(params); Map catalogConfig = optionalConfigMap(params, CATALOG_CONF); - Long snapshot = null; - if (params.has(SNAPSHOT)) { - snapshot = Long.parseLong(params.get(SNAPSHOT)); - } - String tagName = null; if (params.has(TAG_NAME)) { tagName = params.get(TAG_NAME); @@ -63,8 +57,7 @@ public Optional create(MultipleParameterToolAdapter params) { tablePath.f2, catalogConfig, branchName, - tagName, - snapshot); + tagName); return Optional.of(action); } @@ -76,7 +69,7 @@ public void printHelp() { System.out.println("Syntax:"); System.out.println( " create_branch --warehouse --database " - + "--table --branch_name [--tag_name ] [--snapshot ]"); + + "--table --branch_name [--tag_name ]"); System.out.println(); } } diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateBranchProcedure.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateBranchProcedure.java index 3d8ae49cce03..093505923fd6 100644 --- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateBranchProcedure.java +++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateBranchProcedure.java @@ -44,27 +44,19 @@ public String identifier() { public String[] call( ProcedureContext procedureContext, String tableId, String branchName, String tagName) throws Catalog.TableNotExistException { - return innerCall(tableId, branchName, tagName, 0); + return innerCall(tableId, branchName, tagName); } public String[] call(ProcedureContext procedureContext, String tableId, String branchName) throws Catalog.TableNotExistException { - return innerCall(tableId, branchName, null, 0); + return innerCall(tableId, branchName, null); } - public String[] call( - ProcedureContext procedureContext, String tableId, String branchName, long snapshotId) - throws Catalog.TableNotExistException { - return innerCall(tableId, branchName, null, snapshotId); - } - - private String[] innerCall(String tableId, String branchName, String tagName, long snapshotId) + private String[] innerCall(String tableId, String branchName, String tagName) throws Catalog.TableNotExistException { Table table = catalog.getTable(Identifier.fromString(tableId)); if (!StringUtils.isBlank(tagName)) { table.createBranch(branchName, tagName); - } else if (snapshotId > 0) { - table.createBranch(branchName, snapshotId); } else { table.createBranch(branchName); } diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/BranchSqlITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/BranchSqlITCase.java index 33aca03b862c..ba197abfab96 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/BranchSqlITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/BranchSqlITCase.java @@ -54,7 +54,9 @@ public void testAlterBranchTable() throws Exception { + " (2, 10, 'cat')," + " (2, 20, 'dog')"); - sql("CALL sys.create_branch('default.T', 'test', 1)"); + sql("CALL sys.create_tag('default.T', 'tag1', 1)"); + + sql("CALL sys.create_branch('default.T', 'test', 'tag1')"); FileStoreTable branchTable = paimonTable("T$branch_test"); assertThat(branchTable.schema().fields().size()).isEqualTo(3); @@ -134,37 +136,6 @@ public void testCreateBranchFromTag() throws Exception { "+I[2, 20, dog]"); } - @Test - public void testCreateBranchFromSnapshot() throws Exception { - sql( - "CREATE TABLE T (" - + " pt INT" - + ", k INT" - + ", v STRING" - + ", PRIMARY KEY (pt, k) NOT ENFORCED" - + " ) PARTITIONED BY (pt) WITH (" - + " 'bucket' = '2'" - + " )"); - - // snapshot 1. - sql("INSERT INTO T VALUES(1, 10, 'apple')"); - - // snapshot 2. - sql("INSERT INTO T VALUES(1, 20, 'dog')"); - - sql("CALL sys.create_branch('default.T', 'test', 1)"); - sql("CALL sys.create_branch('default.T', 'test2', 2)"); - - assertThat(collectResult("SELECT created_from_snapshot FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[1]", "+I[2]"); - - assertThat(paimonTable("T$branch_test").snapshotManager().snapshotExists(1)) - .isEqualTo(true); - - assertThat(paimonTable("T$branch_test2").snapshotManager().snapshotExists(2)) - .isEqualTo(true); - } - @Test public void testCreateEmptyBranch() throws Exception { sql( @@ -213,8 +184,12 @@ public void testDeleteBranchTable() throws Exception { // snapshot 2. sql("INSERT INTO T VALUES(1, 20, 'dog')"); - sql("CALL sys.create_branch('default.T', 'test', 1)"); - sql("CALL sys.create_branch('default.T', 'test2', 2)"); + sql("CALL sys.create_tag('default.T', 'tag1', 1)"); + + sql("CALL sys.create_tag('default.T', 'tag2', 2)"); + + sql("CALL sys.create_branch('default.T', 'test', 'tag1')"); + sql("CALL sys.create_branch('default.T', 'test2', 'tag2')"); assertThat(collectResult("SELECT branch_name, created_from_snapshot FROM `T$branches`")) .containsExactlyInAnyOrder("+I[test, 1]", "+I[test2, 2]"); @@ -244,9 +219,13 @@ public void testBranchManagerGetBranchSnapshotsList() throws Exception { FileStoreTable table = paimonTable("T"); checkSnapshots(table.snapshotManager(), 1, 3); - sql("CALL sys.create_branch('default.T', 'test1', 1)"); - sql("CALL sys.create_branch('default.T', 'test2', 2)"); - sql("CALL sys.create_branch('default.T', 'test3', 3)"); + sql("CALL sys.create_tag('default.T', 'tag1', 1)"); + sql("CALL sys.create_tag('default.T', 'tag2', 2)"); + sql("CALL sys.create_tag('default.T', 'tag3', 3)"); + + sql("CALL sys.create_branch('default.T', 'test1', 'tag1')"); + sql("CALL sys.create_branch('default.T', 'test2', 'tag2')"); + sql("CALL sys.create_branch('default.T', 'test3', 'tag3')"); assertThat(collectResult("SELECT created_from_snapshot FROM `T$branches`")) .containsExactlyInAnyOrder("+I[1]", "+I[2]", "+I[3]"); @@ -277,7 +256,9 @@ public void testBranchFastForward() throws Exception { .containsExactlyInAnyOrder( "+I[1, 10, hunter]", "+I[1, 20, hunter]", "+I[1, 30, hunter]"); - sql("CALL sys.create_branch('default.T', 'test', 1)"); + sql("CALL sys.create_tag('default.T', 'tag1', 1)"); + + sql("CALL sys.create_branch('default.T', 'test', 'tag1')"); sql("INSERT INTO `T$branch_test` VALUES (2, 10, 'hunterX')"); diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/BranchActionITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/BranchActionITCase.java index a83e618cc998..7b92f0e3c551 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/BranchActionITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/BranchActionITCase.java @@ -119,98 +119,6 @@ void testCreateAndDeleteBranch() throws Exception { assertThat(branchManager.branchExists("branch_name")).isFalse(); } - @Test - void testCreateAndDeleteBranchWithSnapshotId() throws Exception { - - init(warehouse); - - RowType rowType = - RowType.of( - new DataType[] {DataTypes.BIGINT(), DataTypes.STRING()}, - new String[] {"k", "v"}); - FileStoreTable table = - createFileStoreTable( - rowType, - Collections.emptyList(), - Collections.singletonList("k"), - Collections.emptyList(), - Collections.emptyMap()); - - StreamWriteBuilder writeBuilder = table.newStreamWriteBuilder().withCommitUser(commitUser); - write = writeBuilder.newWrite(); - commit = writeBuilder.newCommit(); - - // 3 snapshots - writeData(rowData(1L, BinaryString.fromString("Hi"))); - writeData(rowData(2L, BinaryString.fromString("Hello"))); - writeData(rowData(3L, BinaryString.fromString("Paimon"))); - - BranchManager branchManager = table.branchManager(); - - callProcedure( - String.format( - "CALL sys.create_branch('%s.%s', 'branch_name_with_snapshotId', 2)", - database, tableName)); - assertThat(branchManager.branchExists("branch_name_with_snapshotId")).isTrue(); - - callProcedure( - String.format( - "CALL sys.delete_branch('%s.%s', 'branch_name_with_snapshotId')", - database, tableName)); - assertThat(branchManager.branchExists("branch_name_with_snapshotId")).isFalse(); - - // create branch1 and branch3 - callProcedure( - String.format( - "CALL sys.create_branch('%s.%s', 'branch_name_with_snapshotId_1', 1)", - database, tableName)); - assertThat(branchManager.branchExists("branch_name_with_snapshotId_1")).isTrue(); - - callProcedure( - String.format( - "CALL sys.create_branch('%s.%s', 'branch_name_with_snapshotId_3', 3)", - database, tableName)); - assertThat(branchManager.branchExists("branch_name_with_snapshotId_3")).isTrue(); - - // delete branch1 and branch3 batch - callProcedure( - String.format( - "CALL sys.delete_branch('%s.%s', 'branch_name_with_snapshotId_1,branch_name_with_snapshotId_3')", - database, tableName)); - assertThat(branchManager.branchExists("branch_name_with_snapshotId_1")).isFalse(); - assertThat(branchManager.branchExists("branch_name_with_snapshotId_3")).isFalse(); - - createAction( - CreateBranchAction.class, - "create_branch", - "--warehouse", - warehouse, - "--database", - database, - "--table", - tableName, - "--branch_name", - "branch_name_with_snapshotId", - "--snapshot", - "2") - .run(); - assertThat(branchManager.branchExists("branch_name_with_snapshotId")).isTrue(); - - createAction( - DeleteBranchAction.class, - "delete_branch", - "--warehouse", - warehouse, - "--database", - database, - "--table", - tableName, - "--branch_name", - "branch_name_with_snapshotId") - .run(); - assertThat(branchManager.branchExists("branch_name_with_snapshotId")).isFalse(); - } - @Test void testCreateAndDeleteEmptyBranch() throws Exception { diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/ConsumerActionITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/ConsumerActionITCase.java index 8b3968f95f45..9d507b52f0fa 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/ConsumerActionITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/ConsumerActionITCase.java @@ -146,8 +146,9 @@ public void testResetBranchConsumer() throws Exception { writeData(rowData(2L, BinaryString.fromString("Hello"))); writeData(rowData(3L, BinaryString.fromString("Paimon"))); + table.createTag("tag", 3); String branchName = "b1"; - table.createBranch("b1", 3); + table.createBranch("b1", "tag"); String branchTableName = tableName + "$branch_b1"; // use consumer streaming read table diff --git a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateBranchProcedure.java b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateBranchProcedure.java index 45cfae2e02f9..2a0e0be02b50 100644 --- a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateBranchProcedure.java +++ b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateBranchProcedure.java @@ -26,7 +26,6 @@ import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; -import static org.apache.spark.sql.types.DataTypes.LongType; import static org.apache.spark.sql.types.DataTypes.StringType; /** Spark procedure to create a branch. */ @@ -36,8 +35,7 @@ public class CreateBranchProcedure extends BaseProcedure { new ProcedureParameter[] { ProcedureParameter.required("table", StringType), ProcedureParameter.required("branch", StringType), - ProcedureParameter.optional("tag", StringType), - ProcedureParameter.optional("snapshot", LongType) + ProcedureParameter.optional("tag", StringType) }; private static final StructType OUTPUT_TYPE = @@ -65,15 +63,12 @@ public InternalRow[] call(InternalRow args) { Identifier tableIdent = toIdentifier(args.getString(0), PARAMETERS[0].name()); String branch = args.getString(1); String tag = args.isNullAt(2) ? null : args.getString(2); - Long snapshot = args.isNullAt(3) ? null : args.getLong(3); return modifyPaimonTable( tableIdent, table -> { if (tag != null) { table.createBranch(branch, tag); - } else if (snapshot != null) { - table.createBranch(branch, snapshot); } else { table.createBranch(branch); } diff --git a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/CreateAndDeleteBranchProcedureTest.scala b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/CreateAndDeleteBranchProcedureTest.scala index 59a4b510f1e2..9f9b0e3a9985 100644 --- a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/CreateAndDeleteBranchProcedureTest.scala +++ b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/procedure/CreateAndDeleteBranchProcedureTest.scala @@ -93,13 +93,6 @@ class CreateAndDeleteBranchProcedureTest extends PaimonSparkTestBase with Stream Row(true) :: Nil) assert(branchManager.branchExists("empty_branch")) - // create branch with snapshot - checkAnswer( - spark.sql( - "CALL paimon.sys.create_branch(table => 'test.T', branch => 'snapshot_branch', snapshot => 2)"), - Row(true) :: Nil) - assert(branchManager.branchExists("snapshot_branch")) - // delete branch checkAnswer( spark.sql( @@ -107,28 +100,6 @@ class CreateAndDeleteBranchProcedureTest extends PaimonSparkTestBase with Stream Row(true) :: Nil) assert(!branchManager.branchExists("test_branch")) - // create branch with snapshot2 - checkAnswer( - spark.sql( - "CALL paimon.sys.create_branch(table => 'test.T', branch => 'snapshot_branch_2', snapshot => 2)"), - Row(true) :: Nil) - assert(branchManager.branchExists("snapshot_branch_2")) - - // create branch with snapshot3 - checkAnswer( - spark.sql( - "CALL paimon.sys.create_branch(table => 'test.T', branch => 'snapshot_branch_3', snapshot => 3)"), - Row(true) :: Nil) - assert(branchManager.branchExists("snapshot_branch_3")) - - // delete branch:snapshot_branch_2 and snapshot_branch_3 - checkAnswer( - spark.sql( - "CALL paimon.sys.delete_branch(table => 'test.T', branch => 'snapshot_branch_2,snapshot_branch_3')"), - Row(true) :: Nil) - assert(!branchManager.branchExists("snapshot_branch_2")) - assert(!branchManager.branchExists("snapshot_branch_3")) - } finally { stream.stop() }