48
48
import java .util .List ;
49
49
import java .util .Map ;
50
50
51
+ import static org .apache .seatunnel .api .table .type .CommonOptions .EVENT_TIME ;
52
+
51
53
@ DisabledOnOs (
52
54
value = OS .WINDOWS ,
53
55
disabledReason =
@@ -346,24 +348,33 @@ void testCanalJsonSink() throws IOException {
346
348
Collections .emptyList (),
347
349
"comment" );
348
350
351
+ Map <String , Object > rowOptions = new HashMap <>();
352
+ rowOptions .put (EVENT_TIME .getName (), 1L );
353
+
349
354
SeaTunnelRow row1 = new SeaTunnelRow (new Object [] {1L , "A" , 100 });
350
355
row1 .setRowKind (RowKind .INSERT );
351
356
row1 .setTableId (TablePath .DEFAULT .getFullName ());
357
+ row1 .setOptions (rowOptions );
352
358
SeaTunnelRow row2 = new SeaTunnelRow (new Object [] {2L , "B" , 100 });
353
359
row2 .setRowKind (RowKind .INSERT );
354
360
row2 .setTableId (TablePath .DEFAULT .getFullName ());
361
+ row2 .setOptions (rowOptions );
355
362
SeaTunnelRow row3 = new SeaTunnelRow (new Object [] {3L , "C" , 100 });
356
363
row3 .setRowKind (RowKind .INSERT );
357
364
row3 .setTableId (TablePath .DEFAULT .getFullName ());
365
+ row3 .setOptions (rowOptions );
358
366
SeaTunnelRow row1UpdateBefore = new SeaTunnelRow (new Object [] {1L , "A" , 100 });
359
367
row1UpdateBefore .setTableId (TablePath .DEFAULT .getFullName ());
360
368
row1UpdateBefore .setRowKind (RowKind .UPDATE_BEFORE );
369
+ row1UpdateBefore .setOptions (rowOptions );
361
370
SeaTunnelRow row1UpdateAfter = new SeaTunnelRow (new Object [] {1L , "A_1" , 100 });
362
371
row1UpdateAfter .setTableId (TablePath .DEFAULT .getFullName ());
363
372
row1UpdateAfter .setRowKind (RowKind .UPDATE_AFTER );
373
+ row1UpdateAfter .setOptions (rowOptions );
364
374
SeaTunnelRow row2Delete = new SeaTunnelRow (new Object [] {2L , "B" , 100 });
365
375
row2Delete .setTableId (TablePath .DEFAULT .getFullName ());
366
376
row2Delete .setRowKind (RowKind .DELETE );
377
+ row2Delete .setOptions (rowOptions );
367
378
368
379
SinkFlowTestUtils .runBatchWithCheckpointDisabled (
369
380
catalogTable ,
@@ -379,22 +390,22 @@ void testCanalJsonSink() throws IOException {
379
390
String dataStr = FileUtils .readFileToStr (path );
380
391
Assertions .assertTrue (
381
392
dataStr .contains (
382
- "{\" data\" :[{\" a\" :1,\" b\" :\" A\" ,\" c\" :100}],\" type\" :\" INSERT\" }" ));
393
+ "{\" data\" :[{\" a\" :1,\" b\" :\" A\" ,\" c\" :100}],\" type\" :\" INSERT\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
383
394
Assertions .assertTrue (
384
395
dataStr .contains (
385
- "{\" data\" :[{\" a\" :2,\" b\" :\" B\" ,\" c\" :100}],\" type\" :\" INSERT\" }" ));
396
+ "{\" data\" :[{\" a\" :2,\" b\" :\" B\" ,\" c\" :100}],\" type\" :\" INSERT\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
386
397
Assertions .assertTrue (
387
398
dataStr .contains (
388
- "{\" data\" :[{\" a\" :3,\" b\" :\" C\" ,\" c\" :100}],\" type\" :\" INSERT\" }" ));
399
+ "{\" data\" :[{\" a\" :3,\" b\" :\" C\" ,\" c\" :100}],\" type\" :\" INSERT\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
389
400
Assertions .assertTrue (
390
401
dataStr .contains (
391
- "{\" data\" :[{\" a\" :1,\" b\" :\" A\" ,\" c\" :100}],\" type\" :\" DELETE\" }" ));
402
+ "{\" data\" :[{\" a\" :1,\" b\" :\" A\" ,\" c\" :100}],\" type\" :\" DELETE\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
392
403
Assertions .assertTrue (
393
404
dataStr .contains (
394
- "{\" data\" :[{\" a\" :1,\" b\" :\" A_1\" ,\" c\" :100}],\" type\" :\" INSERT\" }" ));
405
+ "{\" data\" :[{\" a\" :1,\" b\" :\" A_1\" ,\" c\" :100}],\" type\" :\" INSERT\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
395
406
Assertions .assertTrue (
396
407
dataStr .contains (
397
- "{\" data\" :[{\" a\" :2,\" b\" :\" B\" ,\" c\" :100}],\" type\" :\" DELETE\" }" ));
408
+ "{\" data\" :[{\" a\" :2,\" b\" :\" B\" ,\" c\" :100}],\" type\" :\" DELETE\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
398
409
}
399
410
400
411
@ Test
@@ -431,24 +442,33 @@ void testDebeziumJsonSink() throws IOException {
431
442
Collections .emptyList (),
432
443
"comment" );
433
444
445
+ Map <String , Object > rowOptions = new HashMap <>();
446
+ rowOptions .put (EVENT_TIME .getName (), 1L );
447
+
434
448
SeaTunnelRow row1 = new SeaTunnelRow (new Object [] {1L , "A" , 100 });
435
449
row1 .setRowKind (RowKind .INSERT );
436
450
row1 .setTableId (TablePath .DEFAULT .getFullName ());
451
+ row1 .setOptions (rowOptions );
437
452
SeaTunnelRow row2 = new SeaTunnelRow (new Object [] {2L , "B" , 100 });
438
453
row2 .setRowKind (RowKind .INSERT );
439
454
row2 .setTableId (TablePath .DEFAULT .getFullName ());
455
+ row2 .setOptions (rowOptions );
440
456
SeaTunnelRow row3 = new SeaTunnelRow (new Object [] {3L , "C" , 100 });
441
457
row3 .setRowKind (RowKind .INSERT );
442
458
row3 .setTableId (TablePath .DEFAULT .getFullName ());
459
+ row3 .setOptions (rowOptions );
443
460
SeaTunnelRow row1UpdateBefore = new SeaTunnelRow (new Object [] {1L , "A" , 100 });
444
461
row1UpdateBefore .setTableId (TablePath .DEFAULT .getFullName ());
445
462
row1UpdateBefore .setRowKind (RowKind .UPDATE_BEFORE );
463
+ row1UpdateBefore .setOptions (rowOptions );
446
464
SeaTunnelRow row1UpdateAfter = new SeaTunnelRow (new Object [] {1L , "A_1" , 100 });
447
465
row1UpdateAfter .setTableId (TablePath .DEFAULT .getFullName ());
448
466
row1UpdateAfter .setRowKind (RowKind .UPDATE_AFTER );
467
+ row1UpdateAfter .setOptions (rowOptions );
449
468
SeaTunnelRow row2Delete = new SeaTunnelRow (new Object [] {2L , "B" , 100 });
450
469
row2Delete .setTableId (TablePath .DEFAULT .getFullName ());
451
470
row2Delete .setRowKind (RowKind .DELETE );
471
+ row2Delete .setOptions (rowOptions );
452
472
453
473
SinkFlowTestUtils .runBatchWithCheckpointDisabled (
454
474
catalogTable ,
@@ -464,22 +484,22 @@ void testDebeziumJsonSink() throws IOException {
464
484
String dataStr = FileUtils .readFileToStr (path );
465
485
Assertions .assertTrue (
466
486
dataStr .contains (
467
- "{\" before\" :null,\" after\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" op\" :\" c\" }" ));
487
+ "{\" before\" :null,\" after\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" op\" :\" c\" , \" source \" :{ \" schema \" : \" default \" , \" database \" : \" default \" , \" table \" : \" default \" }, \" ts_ms \" :1 }" ));
468
488
Assertions .assertTrue (
469
489
dataStr .contains (
470
- "{\" before\" :null,\" after\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" op\" :\" c\" }" ));
490
+ "{\" before\" :null,\" after\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" op\" :\" c\" , \" source \" :{ \" schema \" : \" default \" , \" database \" : \" default \" , \" table \" : \" default \" }, \" ts_ms \" :1 }" ));
471
491
Assertions .assertTrue (
472
492
dataStr .contains (
473
- "{\" before\" :null,\" after\" :{\" a\" :3,\" b\" :\" C\" ,\" c\" :100},\" op\" :\" c\" }" ));
493
+ "{\" before\" :null,\" after\" :{\" a\" :3,\" b\" :\" C\" ,\" c\" :100},\" op\" :\" c\" , \" source \" :{ \" schema \" : \" default \" , \" database \" : \" default \" , \" table \" : \" default \" }, \" ts_ms \" :1 }" ));
474
494
Assertions .assertTrue (
475
495
dataStr .contains (
476
- "{\" before\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" after\" :null,\" op\" :\" d\" }" ));
496
+ "{\" before\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" after\" :null,\" op\" :\" d\" , \" source \" :{ \" schema \" : \" default \" , \" database \" : \" default \" , \" table \" : \" default \" }, \" ts_ms \" :1 }" ));
477
497
Assertions .assertTrue (
478
498
dataStr .contains (
479
- "{\" before\" :null,\" after\" :{\" a\" :1,\" b\" :\" A_1\" ,\" c\" :100},\" op\" :\" c\" }" ));
499
+ "{\" before\" :null,\" after\" :{\" a\" :1,\" b\" :\" A_1\" ,\" c\" :100},\" op\" :\" c\" , \" source \" :{ \" schema \" : \" default \" , \" database \" : \" default \" , \" table \" : \" default \" }, \" ts_ms \" :1 }" ));
480
500
Assertions .assertTrue (
481
501
dataStr .contains (
482
- "{\" before\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" after\" :null,\" op\" :\" d\" }" ));
502
+ "{\" before\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" after\" :null,\" op\" :\" d\" , \" source \" :{ \" schema \" : \" default \" , \" database \" : \" default \" , \" table \" : \" default \" }, \" ts_ms \" :1 }" ));
483
503
}
484
504
485
505
@ Test
@@ -515,25 +535,33 @@ void testMaxWellJsonSink() throws IOException {
515
535
Collections .emptyMap (),
516
536
Collections .emptyList (),
517
537
"comment" );
538
+ Map <String , Object > rowOptions = new HashMap <>();
539
+ rowOptions .put (EVENT_TIME .getName (), 1L );
518
540
519
541
SeaTunnelRow row1 = new SeaTunnelRow (new Object [] {1L , "A" , 100 });
520
542
row1 .setRowKind (RowKind .INSERT );
521
543
row1 .setTableId (TablePath .DEFAULT .getFullName ());
544
+ row1 .setOptions (rowOptions );
522
545
SeaTunnelRow row2 = new SeaTunnelRow (new Object [] {2L , "B" , 100 });
523
546
row2 .setRowKind (RowKind .INSERT );
524
547
row2 .setTableId (TablePath .DEFAULT .getFullName ());
548
+ row2 .setOptions (rowOptions );
525
549
SeaTunnelRow row3 = new SeaTunnelRow (new Object [] {3L , "C" , 100 });
526
550
row3 .setRowKind (RowKind .INSERT );
527
551
row3 .setTableId (TablePath .DEFAULT .getFullName ());
552
+ row3 .setOptions (rowOptions );
528
553
SeaTunnelRow row1UpdateBefore = new SeaTunnelRow (new Object [] {1L , "A" , 100 });
529
554
row1UpdateBefore .setTableId (TablePath .DEFAULT .getFullName ());
530
555
row1UpdateBefore .setRowKind (RowKind .UPDATE_BEFORE );
556
+ row1UpdateBefore .setOptions (rowOptions );
531
557
SeaTunnelRow row1UpdateAfter = new SeaTunnelRow (new Object [] {1L , "A_1" , 100 });
532
558
row1UpdateAfter .setTableId (TablePath .DEFAULT .getFullName ());
533
559
row1UpdateAfter .setRowKind (RowKind .UPDATE_AFTER );
560
+ row1UpdateAfter .setOptions (rowOptions );
534
561
SeaTunnelRow row2Delete = new SeaTunnelRow (new Object [] {2L , "B" , 100 });
535
562
row2Delete .setTableId (TablePath .DEFAULT .getFullName ());
536
563
row2Delete .setRowKind (RowKind .DELETE );
564
+ row2Delete .setOptions (rowOptions );
537
565
538
566
SinkFlowTestUtils .runBatchWithCheckpointDisabled (
539
567
catalogTable ,
@@ -548,17 +576,22 @@ void testMaxWellJsonSink() throws IOException {
548
576
Path path = Paths .get ("/tmp/seatunnel/LocalFileTest/maxwell_json_file.maxwell_json" );
549
577
String dataStr = FileUtils .readFileToStr (path );
550
578
Assertions .assertTrue (
551
- dataStr .contains ("{\" data\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" type\" :\" INSERT\" }" ));
579
+ dataStr .contains (
580
+ "{\" data\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" type\" :\" INSERT\" ,\" database\" :\" default\" ,\" table\" :\" default\" ,\" ts\" :1}" ));
552
581
Assertions .assertTrue (
553
- dataStr .contains ("{\" data\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" type\" :\" INSERT\" }" ));
582
+ dataStr .contains (
583
+ "{\" data\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" type\" :\" INSERT\" ,\" database\" :\" default\" ,\" table\" :\" default\" ,\" ts\" :1}" ));
554
584
Assertions .assertTrue (
555
- dataStr .contains ("{\" data\" :{\" a\" :3,\" b\" :\" C\" ,\" c\" :100},\" type\" :\" INSERT\" }" ));
585
+ dataStr .contains (
586
+ "{\" data\" :{\" a\" :3,\" b\" :\" C\" ,\" c\" :100},\" type\" :\" INSERT\" ,\" database\" :\" default\" ,\" table\" :\" default\" ,\" ts\" :1}" ));
556
587
Assertions .assertTrue (
557
- dataStr .contains ("{\" data\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" type\" :\" DELETE\" }" ));
588
+ dataStr .contains (
589
+ "{\" data\" :{\" a\" :1,\" b\" :\" A\" ,\" c\" :100},\" type\" :\" DELETE\" ,\" database\" :\" default\" ,\" table\" :\" default\" ,\" ts\" :1}" ));
558
590
Assertions .assertTrue (
559
591
dataStr .contains (
560
- "{\" data\" :{\" a\" :1,\" b\" :\" A_1\" ,\" c\" :100},\" type\" :\" INSERT\" }" ));
592
+ "{\" data\" :{\" a\" :1,\" b\" :\" A_1\" ,\" c\" :100},\" type\" :\" INSERT\" , \" database \" : \" default \" , \" table \" : \" default \" , \" ts \" :1 }" ));
561
593
Assertions .assertTrue (
562
- dataStr .contains ("{\" data\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" type\" :\" DELETE\" }" ));
594
+ dataStr .contains (
595
+ "{\" data\" :{\" a\" :2,\" b\" :\" B\" ,\" c\" :100},\" type\" :\" DELETE\" ,\" database\" :\" default\" ,\" table\" :\" default\" ,\" ts\" :1}" ));
563
596
}
564
597
}
0 commit comments