@@ -22,7 +22,7 @@ public static void test_appender_basic() throws Exception {
22
22
stmt .execute ("CREATE TABLE tab1(col1 INTEGER, col2 VARCHAR)" );
23
23
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
24
24
appender .beginRow ().append (Integer .MAX_VALUE ).append ("foo" ).endRow ();
25
- appender .flush ();
25
+ assertEquals ( appender .flush (), 1L );
26
26
}
27
27
28
28
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -43,7 +43,7 @@ public static void test_appender_null_basic() throws Exception {
43
43
String str = null ;
44
44
appender .beginRow ().append (41 ).append (str ).endRow ();
45
45
appender .beginRow ().append (42 ).appendNull ().endRow ();
46
- appender .flush ();
46
+ assertEquals ( appender .flush (), 2L );
47
47
}
48
48
49
49
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -65,7 +65,7 @@ public static void test_appender_default() throws Exception {
65
65
stmt .execute ("CREATE TABLE tab1(col1 INTEGER DEFAULT 42, col2 VARCHAR DEFAULT 'foo')" );
66
66
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
67
67
appender .beginRow ().appendDefault ().appendDefault ().endRow ();
68
- appender .flush ();
68
+ assertEquals ( appender .flush (), 1L );
69
69
}
70
70
71
71
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -85,7 +85,7 @@ public static void test_appender_boolean() throws Exception {
85
85
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
86
86
appender .beginRow ().append (41 ).append (true ).endRow ();
87
87
appender .beginRow ().append (42 ).append (false ).endRow ();
88
- appender .flush ();
88
+ assertEquals ( appender .flush (), 2L );
89
89
}
90
90
91
91
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -118,7 +118,7 @@ public static void test_appender_unsigned() throws Exception {
118
118
.append (-2 )
119
119
.append ((long ) -2 )
120
120
.endRow ();
121
- appender .flush ();
121
+ assertEquals ( appender .flush (), 2L );
122
122
}
123
123
124
124
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -149,7 +149,7 @@ public static void test_appender_uuid() throws Exception {
149
149
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
150
150
appender .beginRow ().append (1 ).append (uuid1 ).endRow ();
151
151
appender .beginRow ().append (2 ).append (uuid2 ).endRow ();
152
- appender .flush ();
152
+ assertEquals ( appender .flush (), 2L );
153
153
}
154
154
155
155
try (DuckDBResultSet rs =
@@ -182,7 +182,7 @@ public static void test_appender_long_string() throws Exception {
182
182
appender .beginRow ().append (41 ).append (inlineStr ).endRow ();
183
183
appender .beginRow ().append (42 ).append (longStr ).endRow ();
184
184
appender .beginRow ().append (43 ).append (emptyStr ).endRow ();
185
- appender .flush ();
185
+ assertEquals ( appender .flush (), 3L );
186
186
}
187
187
188
188
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -211,7 +211,7 @@ public static void test_appender_huge_integer() throws Exception {
211
211
.append (HUGE_INT_MAX .subtract (BigInteger .ONE ))
212
212
.append (HUGE_INT_MAX .subtract (BigInteger .ONE ))
213
213
.endRow ();
214
- appender .flush ();
214
+ assertEquals ( appender .flush (), 4L );
215
215
}
216
216
217
217
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -253,7 +253,7 @@ public static void test_appender_timestamp_local() throws Exception {
253
253
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
254
254
appender .beginRow ().append (42 ).append (ldt ).append (ldt ).append (ldt ).append (ldt ).endRow ();
255
255
appender .beginRow ().append (43 ).append (dt ).append (dt ).append (dt ).append (dt ).endRow ();
256
- appender .flush ();
256
+ assertEquals ( appender .flush (), 2L );
257
257
}
258
258
259
259
// todo: check rounding rules
@@ -299,7 +299,7 @@ public static void test_appender_timestamp_tz() throws Exception {
299
299
300
300
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
301
301
appender .beginRow ().append (42 ).append (odt ).endRow ();
302
- appender .flush ();
302
+ assertEquals ( appender .flush (), 1L );
303
303
}
304
304
305
305
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -331,7 +331,7 @@ public static void test_appender_time_local() throws Exception {
331
331
332
332
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
333
333
appender .beginRow ().append (42 ).append (lt ).endRow ();
334
- appender .flush ();
334
+ assertEquals ( appender .flush (), 1L );
335
335
}
336
336
337
337
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -371,7 +371,7 @@ public static void test_appender_time_tz() throws Exception {
371
371
372
372
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
373
373
appender .beginRow ().append (42 ).append (ot ).endRow ();
374
- appender .flush ();
374
+ assertEquals ( appender .flush (), 1L );
375
375
}
376
376
377
377
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 ORDER BY col1" )) {
@@ -425,7 +425,8 @@ public static void test_appender_numbers() throws Exception {
425
425
// int8, int4, int2, int1, float8, float4
426
426
stmt .execute ("CREATE TABLE numbers (a BIGINT, b INTEGER, c SMALLINT, d TINYINT, e DOUBLE, f FLOAT)" );
427
427
try (DuckDBAppender appender = conn .createAppender ("numbers" )) {
428
- for (int i = 0 ; i < 50 ; i ++) {
428
+ int count = 50 ;
429
+ for (int i = 0 ; i < count ; i ++) {
429
430
appender .beginRow ()
430
431
.append (Long .MAX_VALUE - i )
431
432
.append (Integer .MAX_VALUE - i )
@@ -435,7 +436,7 @@ public static void test_appender_numbers() throws Exception {
435
436
.append ((float ) i )
436
437
.endRow ();
437
438
}
438
- appender .flush ();
439
+ assertEquals ( appender .flush (), ( long ) count );
439
440
}
440
441
441
442
try (ResultSet rs =
@@ -496,7 +497,8 @@ public static void test_appender_date() throws Exception {
496
497
.beginRow ()
497
498
.append (5 );
498
499
assertThrows (() -> { appender .append (ld5 ); }, SQLException .class );
499
- appender .append (ld4 ).endRow ().flush ();
500
+ long count = appender .append (ld4 ).endRow ().flush ();
501
+ assertEquals (count , 5L );
500
502
}
501
503
502
504
try (ResultSet rs = stmt .executeQuery ("SELECT a FROM date_only ORDER BY id" )) {
@@ -541,7 +543,7 @@ public static void test_appender_string_with_emoji() throws Exception {
541
543
appender .beginRow ().append (2 ).append (cjk1 ).endRow ();
542
544
// append char array
543
545
appender .beginRow ().append (3 ).append (new char [] {cjk1 , cjk2 }).endRow ();
544
- appender .flush ();
546
+ assertEquals ( appender .flush (), 3L );
545
547
}
546
548
547
549
try (ResultSet rs = stmt .executeQuery ("SELECT str_value FROM data ORDER BY id" )) {
@@ -623,7 +625,8 @@ public static void test_appender_null_integer() throws Exception {
623
625
stmt .execute ("CREATE TABLE data (a INTEGER)" );
624
626
625
627
try (DuckDBAppender appender = conn .createAppender (DuckDBConnection .DEFAULT_SCHEMA , "data" )) {
626
- appender .beginRow ().appendNull ().endRow ().flush ();
628
+ long count = appender .beginRow ().appendNull ().endRow ().flush ();
629
+ assertEquals (count , 1L );
627
630
}
628
631
629
632
try (ResultSet results = stmt .executeQuery ("SELECT * FROM data" )) {
@@ -664,42 +667,43 @@ public static void test_appender_decimal() throws Exception {
664
667
"CREATE TABLE decimals (id INT4, a DECIMAL(4,2), b DECIMAL(8,4), c DECIMAL(18,6), d DECIMAL(38,20))" );
665
668
666
669
try (DuckDBAppender appender = conn .createAppender ("decimals" )) {
667
- appender .beginRow ()
668
- .append (1 )
669
- .append (bigdec16 )
670
- .append (bigdec32 )
671
- .append (bigdec64 )
672
- .append (bigdec128 )
673
- .endRow ()
674
- .beginRow ()
675
- .append (2 )
676
- .append (negbigdec16 )
677
- .append (negbigdec32 )
678
- .append (negbigdec64 )
679
- .append (negbigdec128 )
680
- .endRow ()
681
- .beginRow ()
682
- .append (3 )
683
- .append (smallbigdec16 )
684
- .append (smallbigdec32 )
685
- .append (smallbigdec64 )
686
- .append (smallbigdec128 )
687
- .endRow ()
688
- .beginRow ()
689
- .append (4 )
690
- .append (intbigdec16 )
691
- .append (intbigdec32 )
692
- .append (intbigdec64 )
693
- .append (intbigdec128 )
694
- .endRow ()
695
- .beginRow ()
696
- .append (5 )
697
- .append (onebigdec16 )
698
- .append (onebigdec32 )
699
- .append (onebigdec64 )
700
- .append (onebigdec128 )
701
- .endRow ()
702
- .flush ();
670
+ long count = appender .beginRow ()
671
+ .append (1 )
672
+ .append (bigdec16 )
673
+ .append (bigdec32 )
674
+ .append (bigdec64 )
675
+ .append (bigdec128 )
676
+ .endRow ()
677
+ .beginRow ()
678
+ .append (2 )
679
+ .append (negbigdec16 )
680
+ .append (negbigdec32 )
681
+ .append (negbigdec64 )
682
+ .append (negbigdec128 )
683
+ .endRow ()
684
+ .beginRow ()
685
+ .append (3 )
686
+ .append (smallbigdec16 )
687
+ .append (smallbigdec32 )
688
+ .append (smallbigdec64 )
689
+ .append (smallbigdec128 )
690
+ .endRow ()
691
+ .beginRow ()
692
+ .append (4 )
693
+ .append (intbigdec16 )
694
+ .append (intbigdec32 )
695
+ .append (intbigdec64 )
696
+ .append (intbigdec128 )
697
+ .endRow ()
698
+ .beginRow ()
699
+ .append (5 )
700
+ .append (onebigdec16 )
701
+ .append (onebigdec32 )
702
+ .append (onebigdec64 )
703
+ .append (onebigdec128 )
704
+ .endRow ()
705
+ .flush ();
706
+ assertEquals (count , 5L );
703
707
}
704
708
705
709
try (ResultSet rs = stmt .executeQuery ("SELECT a,b,c,d FROM decimals ORDER BY id" )) {
@@ -809,7 +813,7 @@ public static void test_appender_array_basic() throws Exception {
809
813
.append (new int [] {44 , 45 , 46 }, new boolean [] {false , true , false })
810
814
.endRow ();
811
815
appender .beginRow ().append (43 ).appendNull ().endRow ();
812
- appender .flush ();
816
+ assertEquals ( appender .flush (), 3L );
813
817
}
814
818
815
819
try (ResultSet rs = stmt .executeQuery ("SELECT unnest(col2) FROM tab1 WHERE col1 = 41" )) {
@@ -1573,7 +1577,8 @@ public static void test_appender_roundtrip_blob() throws Exception {
1573
1577
stmt .execute ("CREATE TABLE data (a BLOB)" );
1574
1578
1575
1579
try (DuckDBAppender appender = conn .createAppender ("data" )) {
1576
- appender .beginRow ().append (data ).endRow ().flush ();
1580
+ long count = appender .beginRow ().append (data ).endRow ().flush ();
1581
+ assertEquals (count , 1L );
1577
1582
}
1578
1583
1579
1584
try (ResultSet results = stmt .executeQuery ("SELECT * FROM data" )) {
@@ -1592,27 +1597,28 @@ public static void test_appender_struct_basic() throws Exception {
1592
1597
stmt .execute ("CREATE TABLE tab1 (col1 INTEGER, col2 STRUCT(s1 INTEGER, s2 VARCHAR))" );
1593
1598
1594
1599
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
1595
- appender .beginRow ()
1596
- .append (42 )
1597
- .beginStruct ()
1598
- .append (43 )
1599
- .append ("foo" )
1600
- .endStruct ()
1601
- .endRow ()
1602
-
1603
- .beginRow ()
1604
- .append (44 )
1605
- .beginStruct ()
1606
- .append (45 )
1607
- .appendNull ()
1608
- .endStruct ()
1609
- .endRow ()
1610
-
1611
- .beginRow ()
1612
- .append (46 )
1613
- .appendNull ()
1614
- .endRow ()
1615
- .flush ();
1600
+ long count = appender .beginRow ()
1601
+ .append (42 )
1602
+ .beginStruct ()
1603
+ .append (43 )
1604
+ .append ("foo" )
1605
+ .endStruct ()
1606
+ .endRow ()
1607
+
1608
+ .beginRow ()
1609
+ .append (44 )
1610
+ .beginStruct ()
1611
+ .append (45 )
1612
+ .appendNull ()
1613
+ .endStruct ()
1614
+ .endRow ()
1615
+
1616
+ .beginRow ()
1617
+ .append (46 )
1618
+ .appendNull ()
1619
+ .endRow ()
1620
+ .flush ();
1621
+ assertEquals (count , 3L );
1616
1622
}
1617
1623
1618
1624
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1 WHERE col1 = 42" )) {
@@ -1656,14 +1662,15 @@ public static void test_appender_struct_with_array() throws Exception {
1656
1662
stmt .execute ("CREATE TABLE tab1 (col1 INTEGER, col2 STRUCT(s1 INTEGER, s2 INTEGER[2]))" );
1657
1663
1658
1664
try (DuckDBAppender appender = conn .createAppender ("tab1" )) {
1659
- appender .beginRow ()
1660
- .append (42 )
1661
- .beginStruct ()
1662
- .append (43 )
1663
- .append (new int [] {44 , 45 })
1664
- .endStruct ()
1665
- .endRow ()
1666
- .flush ();
1665
+ long count = appender .beginRow ()
1666
+ .append (42 )
1667
+ .beginStruct ()
1668
+ .append (43 )
1669
+ .append (new int [] {44 , 45 })
1670
+ .endStruct ()
1671
+ .endRow ()
1672
+ .flush ();
1673
+ assertEquals (count , 1L );
1667
1674
}
1668
1675
1669
1676
try (ResultSet rs = stmt .executeQuery ("SELECT * FROM tab1" )) {
0 commit comments