Skip to content

Commit

Permalink
Merge pull request #4 from ccri/empty-table
Browse files Browse the repository at this point in the history
Fix exception for empty Table
  • Loading branch information
trxcllnt committed Jan 25, 2018
2 parents 8ddce0a + 7bc7363 commit 272d293
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export class Table implements DataFrame {
}
this.schema = schema;
this.batches = batches;
this.batchesUnion = batches.reduce((union, batch) => union.concat(batch));
this.batchesUnion = batches.length == 0 ?
new RecordBatch(schema, 0, []) :
batches.reduce((union, batch) => union.concat(batch));
this.length = this.batchesUnion.length;
this.numCols = this.batchesUnion.numCols;
}
Expand Down
4 changes: 4 additions & 0 deletions js/test/unit/table-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const {
} = Arrow;

describe(`Table`, () => {
test(`can create an empty table`, () => {
expect(Table.empty().length).toEqual(0)
});

describe(`single record batch`, () => {
const table = Table.from({
'schema': {
Expand Down

0 comments on commit 272d293

Please sign in to comment.