From 91e6d3df1f667adc9207556155ba3b947fe559cb Mon Sep 17 00:00:00 2001 From: herefree <841043203@qq.com> Date: Tue, 10 Sep 2024 17:29:30 +0800 Subject: [PATCH 1/5] remove created_from_snapshot field from BranchesTable --- .../paimon/table/system/BranchesTable.java | 25 +++++------------ .../paimon/flink/CatalogTableITCase.java | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java index a055db6d58cd..a3b2a00d67b2 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java @@ -40,7 +40,6 @@ import org.apache.paimon.table.source.SingletonSplit; import org.apache.paimon.table.source.Split; import org.apache.paimon.table.source.TableRead; -import org.apache.paimon.types.BigIntType; import org.apache.paimon.types.DataField; import org.apache.paimon.types.RowType; import org.apache.paimon.types.TimestampType; @@ -70,7 +69,6 @@ import static org.apache.paimon.utils.BranchManager.BRANCH_PREFIX; import static org.apache.paimon.utils.BranchManager.branchPath; import static org.apache.paimon.utils.FileUtils.listVersionedDirectories; -import static org.apache.paimon.utils.Preconditions.checkArgument; /** A {@link Table} for showing branches of table. */ public class BranchesTable implements ReadonlyTable { @@ -86,8 +84,7 @@ public class BranchesTable implements ReadonlyTable { 0, "branch_name", SerializationUtils.newStringType(false)), new DataField( 1, "created_from_tag", SerializationUtils.newStringType(true)), - new DataField(2, "created_from_snapshot", new BigIntType(true)), - new DataField(3, "create_time", new TimestampType(false, 3)))); + new DataField(2, "create_time", new TimestampType(false, 3)))); private final FileIO fileIO; private final Path location; @@ -238,7 +235,6 @@ private List branches(FileStoreTable table) throws IOException { for (Pair path : paths) { String branchName = path.getLeft().getName().substring(BRANCH_PREFIX.length()); String basedTag = null; - Long basedSnapshotId = null; long creationTime = path.getRight(); Optional tableSchema = @@ -250,20 +246,14 @@ private List branches(FileStoreTable table) throws IOException { SortedMap> snapshotTags = branchTable.tagManager().tags(); Long earliestSnapshotId = branchTable.snapshotManager().earliestSnapshotId(); - if (snapshotTags.isEmpty()) { - // create based on snapshotId - basedSnapshotId = earliestSnapshotId; - } else { + if (!snapshotTags.isEmpty()) { Snapshot snapshot = snapshotTags.firstKey(); - if (Objects.equals(earliestSnapshotId, snapshot.id())) { - // create based on tag - List tags = snapshotTags.get(snapshot); - checkArgument(tags.size() == 1); + if (earliestSnapshotId >= snapshot.id()) { + List tags = + branchTable + .tagManager() + .sortTagsOfOneSnapshot(snapshotTags.get(snapshot)); basedTag = tags.get(0); - basedSnapshotId = snapshot.id(); - } else { - // create based on snapshotId - basedSnapshotId = earliestSnapshotId; } } } @@ -272,7 +262,6 @@ private List branches(FileStoreTable table) throws IOException { GenericRow.of( BinaryString.fromString(branchName), BinaryString.fromString(basedTag), - basedSnapshotId, Timestamp.fromLocalDateTime( DateTimeUtils.toLocalDateTime(creationTime)))); } diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java index 975c6a49007f..9eaa1edf3403 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java @@ -860,6 +860,34 @@ public void testTagsTable() throws Exception { assertThat(result).containsExactly(Row.of("tag1", 1L, 0L, 1L)); } + @Test + public void testBranchesTable() throws Exception { + sql("CREATE TABLE T (a INT, b INT)"); + sql("INSERT INTO T VALUES (1, 2)"); + sql("INSERT INTO T VALUES (3, 4)"); + + paimonTable("T").createTag("tag1", 1); + + paimonTable("T").createBranch("branch1", "tag1"); + + paimonTable("T").createBranch("branch2", "tag1"); + paimonTable("T$branch_branch2").createTag("tag_branch2", 1); + + paimonTable("T").createBranch("branch3"); + sql("INSERT INTO T$branch_branch3 VALUES (3, 4)"); + sql("INSERT INTO T$branch_branch3 VALUES (2, 4)"); + paimonTable("T$branch_branch3").createTag("tag_branch1", 2); + + List result = + sql("SELECT branch_name, created_from_tag FROM T$branches ORDER BY branch_name"); + + assertThat(result) + .containsExactly( + Row.of("branch1", "tag1"), + Row.of("branch2", "tag1"), + Row.of("branch3", null)); + } + @Test public void testConsumersTable() throws Exception { batchSql("CREATE TABLE T (a INT, b INT)"); From ddc6a4b950e19e73daac3768a183931cf401857a Mon Sep 17 00:00:00 2001 From: herefree <841043203@qq.com> Date: Tue, 10 Sep 2024 19:46:19 +0800 Subject: [PATCH 2/5] fix ut --- .../apache/paimon/flink/BranchSqlITCase.java | 39 ++----------------- 1 file changed, 4 insertions(+), 35 deletions(-) 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 6970eb043b25..78aa4175a93e 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 @@ -194,44 +194,13 @@ public void testDeleteBranchTable() throws Exception { 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]"); + assertThat(collectResult("SELECT branch_name, created_from_tag FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test, tag1]", "+I[test2, tag2]"); sql("CALL sys.delete_branch('default.T', 'test')"); - assertThat(collectResult("SELECT branch_name, created_from_snapshot FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test2, 2]"); - } - - @Test - public void testBranchManagerGetBranchSnapshotsList() throws Exception { - sql( - "CREATE TABLE T (" - + " pt INT" - + ", k INT" - + ", v STRING" - + ", PRIMARY KEY (pt, k) NOT ENFORCED" - + " ) PARTITIONED BY (pt) WITH (" - + " 'bucket' = '2'" - + " )"); - - sql("INSERT INTO T VALUES (1, 10, 'hxh')"); - sql("INSERT INTO T VALUES (1, 20, 'hxh')"); - sql("INSERT INTO T VALUES (1, 30, 'hxh')"); - - FileStoreTable table = paimonTable("T"); - checkSnapshots(table.snapshotManager(), 1, 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]"); + assertThat(collectResult("SELECT branch_name, created_from_tag FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test2, tag2]"); } @Test From da9f35da8ead808999f8d7823b4daa3c571c43d9 Mon Sep 17 00:00:00 2001 From: herefree <841043203@qq.com> Date: Tue, 10 Sep 2024 20:24:01 +0800 Subject: [PATCH 3/5] mod --- .../paimon/table/system/BranchesTable.java | 8 +++- .../apache/paimon/flink/BranchSqlITCase.java | 43 +++++++++++++++++-- .../paimon/flink/CatalogTableITCase.java | 10 ++--- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java index a3b2a00d67b2..132eef8ab2af 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java @@ -40,6 +40,7 @@ import org.apache.paimon.table.source.SingletonSplit; import org.apache.paimon.table.source.Split; import org.apache.paimon.table.source.TableRead; +import org.apache.paimon.types.BigIntType; import org.apache.paimon.types.DataField; import org.apache.paimon.types.RowType; import org.apache.paimon.types.TimestampType; @@ -84,7 +85,8 @@ public class BranchesTable implements ReadonlyTable { 0, "branch_name", SerializationUtils.newStringType(false)), new DataField( 1, "created_from_tag", SerializationUtils.newStringType(true)), - new DataField(2, "create_time", new TimestampType(false, 3)))); + new DataField(2, "created_from_snapshot", new BigIntType(true)), + new DataField(3, "create_time", new TimestampType(false, 3)))); private final FileIO fileIO; private final Path location; @@ -235,6 +237,7 @@ private List branches(FileStoreTable table) throws IOException { for (Pair path : paths) { String branchName = path.getLeft().getName().substring(BRANCH_PREFIX.length()); String basedTag = null; + Long basedSnapshotId = null; long creationTime = path.getRight(); Optional tableSchema = @@ -246,6 +249,7 @@ private List branches(FileStoreTable table) throws IOException { SortedMap> snapshotTags = branchTable.tagManager().tags(); Long earliestSnapshotId = branchTable.snapshotManager().earliestSnapshotId(); + if (!snapshotTags.isEmpty()) { Snapshot snapshot = snapshotTags.firstKey(); if (earliestSnapshotId >= snapshot.id()) { @@ -254,6 +258,7 @@ private List branches(FileStoreTable table) throws IOException { .tagManager() .sortTagsOfOneSnapshot(snapshotTags.get(snapshot)); basedTag = tags.get(0); + basedSnapshotId = snapshot.id(); } } } @@ -262,6 +267,7 @@ private List branches(FileStoreTable table) throws IOException { GenericRow.of( BinaryString.fromString(branchName), BinaryString.fromString(basedTag), + basedSnapshotId, Timestamp.fromLocalDateTime( DateTimeUtils.toLocalDateTime(creationTime)))); } 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 78aa4175a93e..5cf9326dab28 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 @@ -169,6 +169,37 @@ public void testCreateEmptyBranch() throws Exception { .containsExactlyInAnyOrder("+I[3, 30, banana]"); } + @Test + public void testBranchManagerGetBranchSnapshotsList() throws Exception { + sql( + "CREATE TABLE T (" + + " pt INT" + + ", k INT" + + ", v STRING" + + ", PRIMARY KEY (pt, k) NOT ENFORCED" + + " ) PARTITIONED BY (pt) WITH (" + + " 'bucket' = '2'" + + " )"); + + sql("INSERT INTO T VALUES (1, 10, 'hxh')"); + sql("INSERT INTO T VALUES (1, 20, 'hxh')"); + sql("INSERT INTO T VALUES (1, 30, 'hxh')"); + + FileStoreTable table = paimonTable("T"); + checkSnapshots(table.snapshotManager(), 1, 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]"); + } + @Test public void testDeleteBranchTable() throws Exception { sql( @@ -194,13 +225,17 @@ public void testDeleteBranchTable() throws Exception { 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_tag FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test, tag1]", "+I[test2, tag2]"); + assertThat( + collectResult( + "SELECT branch_name, created_from_tag, created_from_snapshot FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test, tag1, 1]", "+I[test2, tag2, 2]"); sql("CALL sys.delete_branch('default.T', 'test')"); - assertThat(collectResult("SELECT branch_name, created_from_tag FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test2, tag2]"); + assertThat( + collectResult( + "SELECT branch_name, created_from_tag, created_from_snapshot FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test2, tag2, 2]"); } @Test diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java index 9eaa1edf3403..9f3232020423 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java @@ -879,13 +879,13 @@ public void testBranchesTable() throws Exception { paimonTable("T$branch_branch3").createTag("tag_branch1", 2); List result = - sql("SELECT branch_name, created_from_tag FROM T$branches ORDER BY branch_name"); - + sql( + "SELECT branch_name, created_from_tag, created_from_snapshot FROM T$branches ORDER BY branch_name"); assertThat(result) .containsExactly( - Row.of("branch1", "tag1"), - Row.of("branch2", "tag1"), - Row.of("branch3", null)); + Row.of("branch1", "tag1", 1L), + Row.of("branch2", "tag1", 1L), + Row.of("branch3", null, null)); } @Test From 25cef19d96933ba91786d8ad95dd0348abbb2f06 Mon Sep 17 00:00:00 2001 From: herefree <841043203@qq.com> Date: Wed, 16 Oct 2024 10:54:48 +0800 Subject: [PATCH 4/5] fix --- .../paimon/table/system/BranchesTable.java | 36 ++----------------- .../apache/paimon/flink/BranchSqlITCase.java | 8 ++--- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java index 132eef8ab2af..494d86c12a04 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java @@ -83,10 +83,7 @@ public class BranchesTable implements ReadonlyTable { Arrays.asList( new DataField( 0, "branch_name", SerializationUtils.newStringType(false)), - new DataField( - 1, "created_from_tag", SerializationUtils.newStringType(true)), - new DataField(2, "created_from_snapshot", new BigIntType(true)), - new DataField(3, "create_time", new TimestampType(false, 3)))); + new DataField(1, "create_time", new TimestampType(false, 3)))); private final FileIO fileIO; private final Path location; @@ -112,7 +109,7 @@ public RowType rowType() { @Override public List primaryKeys() { - return Arrays.asList("branch_name", "tag_name"); + return Collections.singletonList("branch_name"); } @Override @@ -226,7 +223,6 @@ public RecordReader createReader(Split split) { private List branches(FileStoreTable table) throws IOException { BranchManager branchManager = table.branchManager(); - SchemaManager schemaManager = new SchemaManager(fileIO, table.location()); List> paths = listVersionedDirectories(fileIO, branchManager.branchDirectory(), BRANCH_PREFIX) @@ -236,38 +232,10 @@ private List branches(FileStoreTable table) throws IOException { for (Pair path : paths) { String branchName = path.getLeft().getName().substring(BRANCH_PREFIX.length()); - String basedTag = null; - Long basedSnapshotId = null; long creationTime = path.getRight(); - - Optional tableSchema = - schemaManager.copyWithBranch(branchName).latest(); - if (tableSchema.isPresent()) { - FileStoreTable branchTable = - FileStoreTableFactory.create( - fileIO, new Path(branchPath(table.location(), branchName))); - SortedMap> snapshotTags = - branchTable.tagManager().tags(); - Long earliestSnapshotId = branchTable.snapshotManager().earliestSnapshotId(); - - if (!snapshotTags.isEmpty()) { - Snapshot snapshot = snapshotTags.firstKey(); - if (earliestSnapshotId >= snapshot.id()) { - List tags = - branchTable - .tagManager() - .sortTagsOfOneSnapshot(snapshotTags.get(snapshot)); - basedTag = tags.get(0); - basedSnapshotId = snapshot.id(); - } - } - } - result.add( GenericRow.of( BinaryString.fromString(branchName), - BinaryString.fromString(basedTag), - basedSnapshotId, Timestamp.fromLocalDateTime( DateTimeUtils.toLocalDateTime(creationTime)))); } 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 5cf9326dab28..a1f7632c85cc 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 @@ -227,15 +227,15 @@ public void testDeleteBranchTable() throws Exception { assertThat( collectResult( - "SELECT branch_name, created_from_tag, created_from_snapshot FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test, tag1, 1]", "+I[test2, tag2, 2]"); + "SELECT branch_name FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test]", "+I[test2]"); sql("CALL sys.delete_branch('default.T', 'test')"); assertThat( collectResult( - "SELECT branch_name, created_from_tag, created_from_snapshot FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test2, tag2, 2]"); + "SELECT branch_name FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test2]"); } @Test From 85cde6f65c21a41592e17327e6e9cf2d6ba679fa Mon Sep 17 00:00:00 2001 From: herefree <841043203@qq.com> Date: Wed, 16 Oct 2024 13:04:13 +0800 Subject: [PATCH 5/5] remove created_from_tag and created_from_snapshot --- docs/content/maintenance/system-tables.md | 12 +++--- .../paimon/table/system/BranchesTable.java | 7 ---- .../ProcedurePositionalArgumentsITCase.java | 8 ++-- .../apache/paimon/flink/BranchSqlITCase.java | 39 +------------------ .../paimon/flink/CatalogTableITCase.java | 28 ------------- 5 files changed, 12 insertions(+), 82 deletions(-) diff --git a/docs/content/maintenance/system-tables.md b/docs/content/maintenance/system-tables.md index a94031e48c5b..78c2b878a8e7 100644 --- a/docs/content/maintenance/system-tables.md +++ b/docs/content/maintenance/system-tables.md @@ -216,12 +216,12 @@ You can query the branches of the table. SELECT * FROM my_table$branches; /* -+----------------------+---------------------------+--------------------------+-------------------------+ -| branch_name | created_from_tag | created_from_snapshot | create_time | -+----------------------+---------------------------+--------------------------+-------------------------+ -| branch1 | tag1 | 2 | 2024-07-18 20:31:39.084 | -| branch2 | tag2 | 5 | 2024-07-18 21:11:14.373 | -+----------------------+---------------------------+--------------------------+-------------------------+ ++----------------------+-------------------------+ +| branch_name | create_time | ++----------------------+-------------------------+ +| branch1 | 2024-07-18 20:31:39.084 | +| branch2 | 2024-07-18 21:11:14.373 | ++----------------------+-------------------------+ 2 rows in set */ ``` diff --git a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java index 494d86c12a04..f523f20e9d20 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/system/BranchesTable.java @@ -18,7 +18,6 @@ package org.apache.paimon.table.system; -import org.apache.paimon.Snapshot; import org.apache.paimon.data.BinaryString; import org.apache.paimon.data.GenericRow; import org.apache.paimon.data.InternalRow; @@ -28,8 +27,6 @@ import org.apache.paimon.fs.Path; import org.apache.paimon.predicate.Predicate; import org.apache.paimon.reader.RecordReader; -import org.apache.paimon.schema.SchemaManager; -import org.apache.paimon.schema.TableSchema; import org.apache.paimon.table.FileStoreTable; import org.apache.paimon.table.FileStoreTableFactory; import org.apache.paimon.table.ReadonlyTable; @@ -40,7 +37,6 @@ import org.apache.paimon.table.source.SingletonSplit; import org.apache.paimon.table.source.Split; import org.apache.paimon.table.source.TableRead; -import org.apache.paimon.types.BigIntType; import org.apache.paimon.types.DataField; import org.apache.paimon.types.RowType; import org.apache.paimon.types.TimestampType; @@ -62,13 +58,10 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; -import java.util.SortedMap; import java.util.stream.Collectors; import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER; import static org.apache.paimon.utils.BranchManager.BRANCH_PREFIX; -import static org.apache.paimon.utils.BranchManager.branchPath; import static org.apache.paimon.utils.FileUtils.listVersionedDirectories; /** A {@link Table} for showing branches of table. */ diff --git a/paimon-flink/paimon-flink-1.18/src/test/java/org/apache/paimon/flink/procedure/ProcedurePositionalArgumentsITCase.java b/paimon-flink/paimon-flink-1.18/src/test/java/org/apache/paimon/flink/procedure/ProcedurePositionalArgumentsITCase.java index 70f2a2f7e2ab..bb461dab6d1f 100644 --- a/paimon-flink/paimon-flink-1.18/src/test/java/org/apache/paimon/flink/procedure/ProcedurePositionalArgumentsITCase.java +++ b/paimon-flink/paimon-flink-1.18/src/test/java/org/apache/paimon/flink/procedure/ProcedurePositionalArgumentsITCase.java @@ -320,13 +320,13 @@ public void testCreateDeleteAndForwardBranch() throws Exception { sql("CALL sys.create_branch('default.T', 'test', 'tag1')"); sql("CALL sys.create_branch('default.T', 'test2', 'tag2')"); - assertThat(collectToString("SELECT branch_name, created_from_snapshot FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test, 1]", "+I[test2, 2]"); + assertThat(collectToString("SELECT branch_name FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test]", "+I[test2]"); sql("CALL sys.delete_branch('default.T', 'test')"); - assertThat(collectToString("SELECT branch_name, created_from_snapshot FROM `T$branches`")) - .containsExactlyInAnyOrder("+I[test2, 2]"); + assertThat(collectToString("SELECT branch_name FROM `T$branches`")) + .containsExactlyInAnyOrder("+I[test2]"); sql("CALL sys.fast_forward('default.T', 'test2')"); 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 a1f7632c85cc..6cf82131f0d9 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 @@ -169,37 +169,6 @@ public void testCreateEmptyBranch() throws Exception { .containsExactlyInAnyOrder("+I[3, 30, banana]"); } - @Test - public void testBranchManagerGetBranchSnapshotsList() throws Exception { - sql( - "CREATE TABLE T (" - + " pt INT" - + ", k INT" - + ", v STRING" - + ", PRIMARY KEY (pt, k) NOT ENFORCED" - + " ) PARTITIONED BY (pt) WITH (" - + " 'bucket' = '2'" - + " )"); - - sql("INSERT INTO T VALUES (1, 10, 'hxh')"); - sql("INSERT INTO T VALUES (1, 20, 'hxh')"); - sql("INSERT INTO T VALUES (1, 30, 'hxh')"); - - FileStoreTable table = paimonTable("T"); - checkSnapshots(table.snapshotManager(), 1, 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]"); - } - @Test public void testDeleteBranchTable() throws Exception { sql( @@ -225,16 +194,12 @@ public void testDeleteBranchTable() throws Exception { sql("CALL sys.create_branch('default.T', 'test', 'tag1')"); sql("CALL sys.create_branch('default.T', 'test2', 'tag2')"); - assertThat( - collectResult( - "SELECT branch_name FROM `T$branches`")) + assertThat(collectResult("SELECT branch_name FROM `T$branches`")) .containsExactlyInAnyOrder("+I[test]", "+I[test2]"); sql("CALL sys.delete_branch('default.T', 'test')"); - assertThat( - collectResult( - "SELECT branch_name FROM `T$branches`")) + assertThat(collectResult("SELECT branch_name FROM `T$branches`")) .containsExactlyInAnyOrder("+I[test2]"); } diff --git a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java index 9f3232020423..975c6a49007f 100644 --- a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java +++ b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java @@ -860,34 +860,6 @@ public void testTagsTable() throws Exception { assertThat(result).containsExactly(Row.of("tag1", 1L, 0L, 1L)); } - @Test - public void testBranchesTable() throws Exception { - sql("CREATE TABLE T (a INT, b INT)"); - sql("INSERT INTO T VALUES (1, 2)"); - sql("INSERT INTO T VALUES (3, 4)"); - - paimonTable("T").createTag("tag1", 1); - - paimonTable("T").createBranch("branch1", "tag1"); - - paimonTable("T").createBranch("branch2", "tag1"); - paimonTable("T$branch_branch2").createTag("tag_branch2", 1); - - paimonTable("T").createBranch("branch3"); - sql("INSERT INTO T$branch_branch3 VALUES (3, 4)"); - sql("INSERT INTO T$branch_branch3 VALUES (2, 4)"); - paimonTable("T$branch_branch3").createTag("tag_branch1", 2); - - List result = - sql( - "SELECT branch_name, created_from_tag, created_from_snapshot FROM T$branches ORDER BY branch_name"); - assertThat(result) - .containsExactly( - Row.of("branch1", "tag1", 1L), - Row.of("branch2", "tag1", 1L), - Row.of("branch3", null, null)); - } - @Test public void testConsumersTable() throws Exception { batchSql("CREATE TABLE T (a INT, b INT)");