apache / apache/arrow-js

[JavaScript] Can't create table if it contains an array of strings ("Unable to infer Vector type")

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

Description

### Describe the bug, including details regarding any error messages, version, and platform.

When using `tableFromArrays()`, I'm seeing the error "Unable to infer Vector type from input values, explicit type declaration expected." for the following code:

```js
const data = {
word: [["a"], ["b"]],
}
const table = tableFromArrays(data)
```

For some reason, `tableFromArrays()` infers the type of each string as a dictionary. Then it compares the IDs of the two dictionaries which are not the same: https://github.com/apache/arrow/blob/main/js/src/visitor/typecomparator.ts#L199.

A more complex example that also produces the error:
```js
const data = {
customers: [{names: ["joe"]}, {names: ["bob"]}],
}
const table = tableFromArrays(data)
```

I would prefer not having the type inferred at all and instead explicitly passing a schema or field type as an argument, but I can't seem to find any documentation on how to do that.

### Component(s)

JavaScript

Contributor guide

Open the contributing guide

Research direction

Start with the tableFromArrays() entry point and reproduce the array-of-strings examples from the issue. Read the type comparison logic in js/src/visitor/typecomparator.ts around line 199, then trace how nested strings are inferred. Done means the reported examples no longer fail, with the supported schema or field-type usage documented if that remains part of the resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.