diff --git a/src/build/column-from-array.js b/src/build/column-from-array.js index 9e8b7da..280cbd4 100644 --- a/src/build/column-from-array.js +++ b/src/build/column-from-array.js @@ -42,9 +42,10 @@ function columnFromTypedArray(values, { maxBatchRows, useBigInt }) { const batches = []; const batchType = isInt64ArrayType(arrayType) && !useBigInt ? Int64Batch : DirectBatch; const add = (start, end) => batches.push(new batchType({ - length: limit, + length: end - start, nullCount: 0, type, + validity: new uint8Array(0), values: values.subarray(start, end) })); diff --git a/test/column-from-array-test.js b/test/column-from-array-test.js index 8254bab..9754e47 100644 --- a/test/column-from-array-test.js +++ b/test/column-from-array-test.js @@ -382,6 +382,13 @@ describe('columnFromArray', () => { assert.strictEqual(col.nullCount, 10); assert.strictEqual(col.data.length, 4); assert.deepStrictEqual(col.data.map(d => d.length), [10, 10, 10, 3]); + + const floats = Float64Array.from({ length: 10 }, Math.random); + const tcol = test(floats, null, { maxBatchRows: 4 }); + assert.strictEqual(tcol.nullCount, 0); + assert.strictEqual(tcol.length, 10); + assert.strictEqual(tcol.data.length, 3); + assert.deepStrictEqual(tcol.data.map(d => d.length), [4, 4, 2]); }); it('builds columns from typed arrays', () => {