Skip to content

Commit d7fa7a1

Browse files
rustyconoverclaude
andcommitted
refactor: generate zero-column test data on-demand instead of checking in binary
Remove test/data/zero_column_batch.arrow and generate IPC buffer in the test using the JS writer, per review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dfa2b0f commit d7fa7a1

2 files changed

Lines changed: 18 additions & 33 deletions

File tree

test/data/zero_column_batch.arrow

-144 Bytes
Binary file not shown.

test/unit/ipc/reader/zero-column-batch-tests.ts

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717

1818
import '../../../jest-extensions.js';
19-
import { readFileSync } from 'node:fs';
20-
import path from 'node:path';
2119
import {
2220
makeData,
2321
RecordBatch,
@@ -27,14 +25,28 @@ import {
2725
tableFromIPC,
2826
} from 'apache-arrow';
2927

30-
const testDataDir = path.resolve(process.cwd(), 'test/data');
28+
/** Helper to create a zero-column IPC stream buffer with the given number of rows. */
29+
function createZeroColumnIPCBuffer(numRows: number): Uint8Array {
30+
const schema = new Schema([]);
31+
const data = makeData({
32+
type: new Struct([]),
33+
length: numRows,
34+
nullCount: 0,
35+
children: [],
36+
});
37+
const batch = new RecordBatch(schema, data);
38+
const writer = new RecordBatchStreamWriter();
39+
writer.write(batch);
40+
writer.finish();
41+
return writer.toUint8Array(true);
42+
}
3143

3244
describe('Zero-column RecordBatch numRows preservation', () => {
3345

34-
describe('PyArrow interop', () => {
46+
describe('IPC round-trip', () => {
3547

36-
test('should read PyArrow zero-column stream and preserve numRows', () => {
37-
const buffer = readFileSync(path.resolve(testDataDir, 'zero_column_batch.arrow'));
48+
test('should read zero-column stream and preserve numRows', () => {
49+
const buffer = createZeroColumnIPCBuffer(100);
3850
const table = tableFromIPC(buffer);
3951

4052
expect(table.numRows).toBe(100);
@@ -44,33 +56,6 @@ describe('Zero-column RecordBatch numRows preservation', () => {
4456
});
4557
});
4658

47-
describe('JS round-trip', () => {
48-
49-
test('zero-column batch should round-trip through IPC stream writer', () => {
50-
const schema = new Schema([]);
51-
const data = makeData({
52-
type: new Struct([]),
53-
length: 100,
54-
nullCount: 0,
55-
children: [],
56-
});
57-
const batch = new RecordBatch(schema, data);
58-
expect(batch.numRows).toBe(100);
59-
expect(batch.numCols).toBe(0);
60-
61-
const writer = new RecordBatchStreamWriter();
62-
writer.write(batch);
63-
writer.finish();
64-
const buffer = writer.toUint8Array(true);
65-
66-
const table = tableFromIPC(buffer);
67-
expect(table.numRows).toBe(100);
68-
expect(table.numCols).toBe(0);
69-
expect(table.batches).toHaveLength(1);
70-
expect(table.batches[0].numRows).toBe(100);
71-
});
72-
});
73-
7459
describe('Direct constructor', () => {
7560

7661
test('RecordBatch constructor preserves length for zero-column data', () => {

0 commit comments

Comments
 (0)