Skip to content

Commit

Permalink
[core] Add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
schnappi17 committed Mar 13, 2024
1 parent 760adb4 commit b282b30
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import static org.apache.paimon.io.DataFileTestUtils.row;
import static org.apache.paimon.predicate.PredicateBuilder.and;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/** Tests for {@link PrimaryKeyFileStoreTable}. */
Expand Down Expand Up @@ -323,6 +324,33 @@ public void testBranchStreamingReadWrite() throws Exception {
"+2|22|202|binary|varbinary|mapKey:mapVal|multiset"));
}

@Test
public void testCompactOnBranch() throws Exception {
FileStoreTable table = createFileStoreTable(conf -> conf.set(CHANGELOG_PRODUCER, LOOKUP));
IOManager ioManager = IOManager.create(tablePath.toString());
try (StreamTableWrite write = table.newWrite(commitUser).withIOManager(ioManager);
StreamTableCommit commit = table.newCommit(commitUser)) {
write.write(rowData(0, 0, 0L));
commit.commit(0, write.prepareCommit(false, 0));

write.write(rowData(1, 10, 1000L));
write.write(rowData(2, 21, 201L));
write.write(rowData(2, 21, 2001L));
commit.commit(1, write.prepareCommit(false, 1));

write.write(rowData(1, 11, 1001L));
write.write(rowData(2, 22, 202L));
write.write(rowData(2, 22, 2002L));
commit.commit(2, write.prepareCommit(false, 2));
}

// create branch from a historical tag, not the latest
table.createTag("tag1", 1);
table.createBranch(BRANCH_NAME, "tag1");

assertThatCode(() -> writeBranchData(table)).doesNotThrowAnyException();
}

@Test
public void testStreamingProjection() throws Exception {
writeData();
Expand Down Expand Up @@ -621,7 +649,9 @@ private void writeData() throws Exception {
}

private void writeBranchData(FileStoreTable table) throws Exception {
StreamTableWrite write = table.newWrite(commitUser);
IOManager ioManager = IOManager.create(tablePath.toString());
StreamTableWrite write =
table.newWrite(commitUser, null, BRANCH_NAME).withIOManager(ioManager);
StreamTableCommit commit = table.newCommit(commitUser, BRANCH_NAME);

write.write(rowData(1, 10, 100L));
Expand Down

0 comments on commit b282b30

Please sign in to comment.