58
58
import org .junit .jupiter .api .Assertions ;
59
59
import org .junit .jupiter .api .io .TempDir ;
60
60
import org .junit .jupiter .params .ParameterizedTest ;
61
- import org .junit .jupiter .params .provider .ValueSource ;
61
+ import org .junit .jupiter .params .provider .CsvSource ;
62
62
63
63
import java .io .File ;
64
64
import java .io .IOException ;
@@ -140,7 +140,7 @@ private void initialize(String metastore)
140
140
.dropDatabase (TEST_DATABASE , true , true );
141
141
}
142
142
143
- private List <Event > createTestEvents () throws SchemaEvolveException {
143
+ private List <Event > createTestEvents (boolean enableDeleteVectors ) throws SchemaEvolveException {
144
144
List <Event > testEvents = new ArrayList <>();
145
145
// create table
146
146
Schema schema =
@@ -149,6 +149,7 @@ private List<Event> createTestEvents() throws SchemaEvolveException {
149
149
.physicalColumn ("col2" , DataTypes .STRING ())
150
150
.primaryKey ("col1" )
151
151
.option ("bucket" , "1" )
152
+ .option ("deletion-vectors.enabled" , String .valueOf (enableDeleteVectors ))
152
153
.build ();
153
154
CreateTableEvent createTableEvent = new CreateTableEvent (table1 , schema );
154
155
testEvents .add (createTableEvent );
@@ -180,8 +181,8 @@ private List<Event> createTestEvents() throws SchemaEvolveException {
180
181
}
181
182
182
183
@ ParameterizedTest
183
- @ ValueSource ( strings = { "filesystem" , "hive" })
184
- public void testSinkWithDataChange (String metastore )
184
+ @ CsvSource ({ "filesystem, true" , "filesystem, false " , "hive, true" , "hive, false " })
185
+ public void testSinkWithDataChange (String metastore , boolean enableDeleteVector )
185
186
throws IOException , InterruptedException , Catalog .DatabaseNotEmptyException ,
186
187
Catalog .DatabaseNotExistException , SchemaEvolveException {
187
188
initialize (metastore );
@@ -192,7 +193,7 @@ public void testSinkWithDataChange(String metastore)
192
193
Committer <MultiTableCommittable > committer = paimonSink .createCommitter ();
193
194
194
195
// insert
195
- for (Event event : createTestEvents ()) {
196
+ for (Event event : createTestEvents (enableDeleteVector )) {
196
197
writer .write (event , null );
197
198
}
198
199
writer .flush (false );
@@ -215,7 +216,7 @@ public void testSinkWithDataChange(String metastore)
215
216
// delete
216
217
Event event =
217
218
DataChangeEvent .deleteEvent (
218
- TableId . tableId ( "test" , " table1" ) ,
219
+ table1 ,
219
220
generator .generate (
220
221
new Object [] {
221
222
BinaryStringData .fromString ("1" ),
@@ -240,7 +241,7 @@ public void testSinkWithDataChange(String metastore)
240
241
// update
241
242
event =
242
243
DataChangeEvent .updateEvent (
243
- TableId . tableId ( "test" , " table1" ) ,
244
+ table1 ,
244
245
generator .generate (
245
246
new Object [] {
246
247
BinaryStringData .fromString ("2" ),
@@ -273,17 +274,19 @@ public void testSinkWithDataChange(String metastore)
273
274
.collect ()
274
275
.forEachRemaining (result ::add );
275
276
// Each commit will generate one sequence number(equal to checkpointId).
276
- Assertions .assertEquals (
277
- Arrays .asList (
278
- Row .ofKind (RowKind .INSERT , 1L ),
279
- Row .ofKind (RowKind .INSERT , 2L ),
280
- Row .ofKind (RowKind .INSERT , 3L )),
281
- result );
277
+ List <Row > expected =
278
+ enableDeleteVector
279
+ ? Collections .singletonList (Row .ofKind (RowKind .INSERT , 3L ))
280
+ : Arrays .asList (
281
+ Row .ofKind (RowKind .INSERT , 1L ),
282
+ Row .ofKind (RowKind .INSERT , 2L ),
283
+ Row .ofKind (RowKind .INSERT , 3L ));
284
+ Assertions .assertEquals (expected , result );
282
285
}
283
286
284
287
@ ParameterizedTest
285
- @ ValueSource ( strings = { "filesystem" , "hive" })
286
- public void testSinkWithSchemaChange (String metastore )
288
+ @ CsvSource ({ "filesystem, true" , "filesystem, false " , "hive, true" , "hive, false " })
289
+ public void testSinkWithSchemaChange (String metastore , boolean enableDeleteVector )
287
290
throws IOException , InterruptedException , Catalog .DatabaseNotEmptyException ,
288
291
Catalog .DatabaseNotExistException , SchemaEvolveException {
289
292
initialize (metastore );
@@ -294,7 +297,7 @@ public void testSinkWithSchemaChange(String metastore)
294
297
Committer <MultiTableCommittable > committer = paimonSink .createCommitter ();
295
298
296
299
// 1. receive only DataChangeEvents during one checkpoint
297
- for (Event event : createTestEvents ()) {
300
+ for (Event event : createTestEvents (enableDeleteVector )) {
298
301
writer .write (event , null );
299
302
}
300
303
writer .flush (false );
@@ -427,8 +430,8 @@ public void testSinkWithSchemaChange(String metastore)
427
430
}
428
431
429
432
@ ParameterizedTest
430
- @ ValueSource ( strings = { "filesystem" , "hive" })
431
- public void testSinkWithMultiTables (String metastore )
433
+ @ CsvSource ({ "filesystem, true" , "filesystem, false " , "hive, true" , "hive, false " })
434
+ public void testSinkWithMultiTables (String metastore , boolean enableDeleteVector )
432
435
throws IOException , InterruptedException , Catalog .DatabaseNotEmptyException ,
433
436
Catalog .DatabaseNotExistException , SchemaEvolveException {
434
437
initialize (metastore );
@@ -437,7 +440,7 @@ public void testSinkWithMultiTables(String metastore)
437
440
catalogOptions , new PaimonRecordEventSerializer (ZoneId .systemDefault ()));
438
441
PaimonWriter <Event > writer = paimonSink .createWriter (new MockInitContext ());
439
442
Committer <MultiTableCommittable > committer = paimonSink .createCommitter ();
440
- List <Event > testEvents = createTestEvents ();
443
+ List <Event > testEvents = createTestEvents (enableDeleteVector );
441
444
// create table
442
445
TableId table2 = TableId .tableId ("test" , "table2" );
443
446
Schema schema =
@@ -492,8 +495,8 @@ public void testSinkWithMultiTables(String metastore)
492
495
}
493
496
494
497
@ ParameterizedTest
495
- @ ValueSource ( strings = { "filesystem" , "hive" })
496
- public void testDuplicateCommitAfterRestore (String metastore )
498
+ @ CsvSource ({ "filesystem, true" , "filesystem, false " , "hive, true" , "hive, false " })
499
+ public void testDuplicateCommitAfterRestore (String metastore , boolean enableDeleteVector )
497
500
throws IOException , InterruptedException , Catalog .DatabaseNotEmptyException ,
498
501
Catalog .DatabaseNotExistException , SchemaEvolveException {
499
502
initialize (metastore );
@@ -504,7 +507,7 @@ public void testDuplicateCommitAfterRestore(String metastore)
504
507
Committer <MultiTableCommittable > committer = paimonSink .createCommitter ();
505
508
506
509
// insert
507
- for (Event event : createTestEvents ()) {
510
+ for (Event event : createTestEvents (enableDeleteVector )) {
508
511
writer .write (event , null );
509
512
}
510
513
writer .flush (false );
@@ -553,8 +556,13 @@ public void testDuplicateCommitAfterRestore(String metastore)
553
556
.execute ()
554
557
.collect ()
555
558
.forEachRemaining (result ::add );
556
- // 8 APPEND and 1 COMPACT
557
- Assertions .assertEquals (result .size (), 9 );
559
+ if (enableDeleteVector ) {
560
+ // Each APPEND will trigger COMPACT once enable deletion-vectors.
561
+ Assertions .assertEquals (16 , result .size ());
562
+ } else {
563
+ // 8 APPEND and 1 COMPACT
564
+ Assertions .assertEquals (9 , result .size ());
565
+ }
558
566
result .clear ();
559
567
560
568
tEnv .sqlQuery ("select * from paimon_catalog.test.`table1`" )
0 commit comments