Skip to content

Commit

Permalink
remove created_from_tag and created_from_snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
herefree committed Oct 16, 2024
1 parent 25cef19 commit 85cde6f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 82 deletions.
12 changes: 6 additions & 6 deletions docs/content/maintenance/system-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Row> 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)");
Expand Down

0 comments on commit 85cde6f

Please sign in to comment.