Commit c23916c
fix: Preserve numRows for zero-column RecordBatch in IPC (#402)
## Summary
When a zero-column RecordBatch is deserialized from IPC,
`ensureSameLengthData`
in the `RecordBatch` constructor recomputes length from children via
`chunks.reduce((max, col) => Math.max(max, col.length), 0)`. With zero
children,
this always returns 0 — discarding the original length from the IPC
message header.
Other Arrow implementations (PyArrow, Arrow Go, arrow-rs) correctly
preserve
numRows for zero-column batches.
## Fix
Pass `this.data.length` to `ensureSameLengthData` as the explicit
`maxLength`
parameter, which the function already accepts as an optional third
argument.
For batches with columns, `this.data.length` already matches the max
column
length, so there is no behavior change.
## Tests
- Read a PyArrow-generated zero-column IPC stream (100 rows) and verify
numRows
- JS round-trip: write + read zero-column batch, verify numRows
preserved
- Direct constructor: verify zero-column RecordBatch preserves length
Closes #401
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent ed42d66 commit c23916c
File tree
2 files changed
+76
-1
lines changed- src
- test/unit/ipc/reader
2 files changed
+76
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
0 commit comments