rustyconover opened a new issue, #403:
URL: https://github.com/apache/arrow-js/issues/403
## Description
In `src/data.ts`, `visitStruct` computes a default `length` via:
```typescript
length = children.reduce((len, { length }) => Math.max(len, length), 0),
```
When `children` is `[]` and `props.length` is omitted, `reduce` returns `0`.
This silently discards any intended row count for zero-child Struct data.
## Impact
Two callers in `src/recordbatch.ts` omit `length` when calling `makeData`
for Struct types:
- **`setChildAt`** (line 264): `makeData({ type: new Struct<T>(fields),
children })` — should pass `length: data.length` to preserve the batch's row
count
- **`_InternalEmptyPlaceholderRecordBatch`** (line 383): `makeData({ type:
new Struct<T>(schema.fields), nullCount: 0, children })` — should pass `length:
0` explicitly
Both work today because they always have children to reduce over, but
they're fragile — any future change that results in empty children would
silently drop the row count.
## Proposed Fix
Pass explicit `length` in both `makeData` call sites so they don't rely on
the reduce-over-children fallback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]