Skip to content

Commit 78f99e4

Browse files
authored
[test] Add test of compact conflict with overwrite upgrade (#6864)
1 parent 88e2aa2 commit 78f99e4

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

paimon-core/src/test/java/org/apache/paimon/table/sink/TableCommitTest.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,4 +869,58 @@ public void testOverwriteEmptyTable(boolean partitioned) throws Exception {
869869
.isEqualTo(Snapshot.CommitKind.APPEND);
870870
}
871871
}
872+
873+
@Test
874+
public void testCompactConflictWithUpgrade() throws Exception {
875+
String path = tempDir.toString();
876+
RowType rowType =
877+
RowType.of(
878+
new DataType[] {DataTypes.INT(), DataTypes.INT()}, new String[] {"k", "v"});
879+
880+
Options options = new Options();
881+
options.set(CoreOptions.PATH, path);
882+
options.set(CoreOptions.BUCKET, 1);
883+
TableSchema tableSchema =
884+
SchemaUtils.forceCommit(
885+
new SchemaManager(LocalFileIO.create(), new Path(path)),
886+
new Schema(
887+
rowType.getFields(),
888+
Collections.emptyList(),
889+
Collections.singletonList("k"),
890+
options.toMap(),
891+
""));
892+
FileStoreTable table =
893+
FileStoreTableFactory.create(
894+
LocalFileIO.create(),
895+
new Path(path),
896+
tableSchema,
897+
CatalogEnvironment.empty());
898+
String user1 = UUID.randomUUID().toString();
899+
FileStoreTable overwriteUpgrade =
900+
table.copy(Collections.singletonMap("write-only", "true"));
901+
TableWriteImpl<?> write1 = overwriteUpgrade.newWrite(user1);
902+
TableCommitImpl commit1 =
903+
overwriteUpgrade.newCommit(user1).withOverwrite(Collections.emptyMap());
904+
905+
String user2 = UUID.randomUUID().toString();
906+
FileStoreTable compactTable =
907+
table.copy(Collections.singletonMap("compaction.force-up-level-0", "true"));
908+
TableWriteImpl<?> write2 = compactTable.newWrite(user2);
909+
TableCommitImpl commit2 = compactTable.newCommit(user2);
910+
911+
write1.write(GenericRow.of(1, 1));
912+
write1.write(GenericRow.of(3, 3));
913+
914+
write2.write(GenericRow.of(2, 2));
915+
write2.write(GenericRow.of(4, 4));
916+
917+
commit1.commit(1, write1.prepareCommit(false, 1));
918+
assertThatThrownBy(() -> commit2.commit(1, write2.prepareCommit(true, 1)))
919+
.hasMessageContaining("LSM conflicts detected! Give up committing.");
920+
921+
write1.close();
922+
commit1.close();
923+
write2.close();
924+
commit2.close();
925+
}
872926
}

0 commit comments

Comments
 (0)