apache / apache/arrow-js

[JS] toArray() method ignores nulls on some types.

Open
#105 2 comments 0 reactions 0 assignees View on GitHub
Type: bug
Dominant language
TypeScript
Stars
112
Forks
23
Avg merge
21h 18m
Merged PRs (30d)
8

Description

The .toArray() javascript method of vectors includes a shortcut to return the underlying typed array; but this doesn't respect null values, and so can return the wrong number.

 

```

v = arrow.Vector.from(\{values: [1, 2, 3, 4, 5, null, 6],type: new arrow.Int32()})

v.toArray()[5] // Incorrectly returns '0'

v.get(5) // Correctly returns null

```

 

Solution: Eliminate the fast method, always return Javascript arrays. It might be better to keep the old method in cases where there are guaranteed no nulls.

**Reporter**: [Ben Schmidt](https://issues.apache.org/jira/browse/ARROW-10221) / @bmschmidt
#### Externally tracked issue: [https://github.com/apache/arrow/pull/8385](https://github.com/apache/arrow/pull/8385)
#### PRs and other links:
- [GitHub Pull Request apache/arrow#8385](https://github.com/apache/arrow/pull/8385)

**Note**: *This issue was originally created as [ARROW-10221](https://issues.apache.org/jira/browse/ARROW-10221). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.