File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ export class DuckDBDataChunk {
32
32
return duckdb . data_chunk_get_size ( this . chunk ) ;
33
33
}
34
34
public set rowCount ( count : number ) {
35
+ const maxRowCount = duckdb . vector_size ( ) ;
36
+ if ( count > maxRowCount ) {
37
+ throw new Error ( `A data chunk cannot have more than ${ maxRowCount } rows` ) ;
38
+ }
35
39
duckdb . data_chunk_set_size ( this . chunk , count ) ;
36
40
}
37
41
public getColumnVector ( columnIndex : number ) : DuckDBVector {
Original file line number Diff line number Diff line change @@ -1471,6 +1471,17 @@ describe('api', () => {
1471
1471
const connection = await DuckDBConnection . create ( ) ;
1472
1472
await connection . run ( 'select 1' ) ;
1473
1473
} ) ;
1474
+ test ( 'data chunk max rows' , ( ) => {
1475
+ try {
1476
+ DuckDBDataChunk . create ( [ INTEGER ] , 2049 ) ;
1477
+ assert . fail ( 'should throw' ) ;
1478
+ } catch ( err ) {
1479
+ assert . deepEqual (
1480
+ err ,
1481
+ new Error ( 'A data chunk cannot have more than 2048 rows' )
1482
+ ) ;
1483
+ }
1484
+ } ) ;
1474
1485
test ( 'write integer vector' , ( ) => {
1475
1486
const chunk = DuckDBDataChunk . create ( [ INTEGER ] , 3 ) ;
1476
1487
const vector = chunk . getColumnVector ( 0 ) as DuckDBIntegerVector ;
You can’t perform that action at this time.
0 commit comments