Skip to content

Commit 197f86d

Browse files
author
yuzelin
committed
fix
1 parent 6f77d03 commit 197f86d

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ public void testStrictModeForAppend() throws Exception {
392392

393393
Options options = new Options();
394394
options.set(CoreOptions.PATH, path);
395+
options.set(CoreOptions.BUCKET, 1);
395396
options.set(CoreOptions.NUM_SORTED_RUNS_COMPACTION_TRIGGER, 10);
396397
TableSchema tableSchema =
397398
SchemaUtils.forceCommit(
@@ -409,8 +410,7 @@ public void testStrictModeForAppend() throws Exception {
409410
tableSchema,
410411
CatalogEnvironment.empty());
411412
String user1 = UUID.randomUUID().toString();
412-
FileStoreTable fixedBucketWriteTable =
413-
table.copy(singletonMap(CoreOptions.BUCKET.key(), "1"));
413+
FileStoreTable fixedBucketWriteTable = table;
414414
TableWriteImpl<?> write1 = fixedBucketWriteTable.newWrite(user1);
415415
TableCommitImpl commit1 = fixedBucketWriteTable.newCommit(user1);
416416

@@ -430,33 +430,34 @@ public void testStrictModeForAppend() throws Exception {
430430
write2.write(GenericRow.of(1, 1L));
431431
commit2.commit(1, write2.prepareCommit(false, 1));
432432

433-
// APPEND with fixed bucket files should be checked
434-
write1.write(GenericRow.of(2, 2L));
435-
commit1.commit(2, write1.prepareCommit(false, 2));
436-
437-
write2.write(GenericRow.of(3, 3L));
438-
commit2.commit(2, write2.prepareCommit(false, 2));
439-
440-
assertThatThrownBy(() -> commit2.commit(2, write2.prepareCommit(false, 2)))
441-
.isInstanceOf(RuntimeException.class)
442-
.hasMessageContaining(
443-
"Giving up committing as commit.strict-mode.last-safe-snapshot is set.");
444-
445433
// APPEND with postpone bucket files should be ignored
434+
write1.close();
435+
commit1.close();
446436
Map<String, String> postponeWriteOptions = new HashMap<>();
447437
postponeWriteOptions.put(CoreOptions.BUCKET.key(), "-2");
448438
postponeWriteOptions.put(CoreOptions.POSTPONE_BATCH_WRITE_FIXED_BUCKET.key(), "false");
449439
FileStoreTable postponeWriteTable = fixedBucketWriteTable.copy(postponeWriteOptions);
450-
write1.close();
451-
commit1.close();
452440
write1 = postponeWriteTable.newWrite(user1);
453441
commit1 = postponeWriteTable.newCommit(user1);
442+
write1.write(GenericRow.of(2, 2L));
443+
commit1.commit(2, write1.prepareCommit(false, 2));
444+
445+
write2.write(GenericRow.of(3, 3L));
446+
commit2.commit(2, write2.prepareCommit(false, 2));
454447

448+
// APPEND with fixed bucket files should be checked
449+
write1.close();
450+
commit1.close();
451+
write1 = fixedBucketWriteTable.newWrite(user1);
452+
commit1 = fixedBucketWriteTable.newCommit(user1);
455453
write1.write(GenericRow.of(4, 4L));
456454
commit1.commit(3, write1.prepareCommit(true, 3));
457455

458456
write2.write(GenericRow.of(5, 5L));
459-
commit2.commit(3, write2.prepareCommit(false, 3));
457+
assertThatThrownBy(() -> commit2.commit(3, write2.prepareCommit(false, 3)))
458+
.isInstanceOf(RuntimeException.class)
459+
.hasMessageContaining(
460+
"Giving up committing as commit.strict-mode.last-safe-snapshot is set.");
460461
}
461462

462463
@Test

0 commit comments

Comments
 (0)