[JS] Creating element with JS arrays returns "0" instead of "undefined" for missing elements.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, typescript
- Domain
- data
Research direction
Start with the tableFromArrays example in the issue and reproduce it from the linked StackBlitz main.js entry point. Trace how the regular JavaScript array becomes the Vector and how Vector.get handles indexes beyond its length, comparing it with the Float64Array case. Done means the array-backed vector returns undefined for the same out-of-range access while preserving the reported table and vector lengths.
Written by the indexing model from the issue text.
Description
Describe the bug, including details regarding any error messages, version, and platform.
When creating a table using regular JavaScript Array syntax, the resulting Vector gives unexpected results:
import { tableFromArrays } from 'https://cdn.skypack.dev/apache-arrow@15.0.2';
const table = tableFromArrays({
a: new Float64Array([100, 200, 300]),
b: [100, 200, 300],
});
console.log('Table rows:', table.numRows);
const vectorA = table.getChild('a');
const vectorB = table.getChild('b');
console.log('Length of "a":', vectorA.length);
console.log('Length of "b":', vectorB.length);
console.log('Element "a" at index 3:', vectorA.get(3));
console.log('Element "b" at index 3:', vectorB.get(3));
console.log('Element "a" at index 100:', vectorA.get(100));
console.log('Element "b" at index 100:', vectorB.get(100));
console.log('Vector "a" internal data length:', vectorA.data[0].values.length);
console.log('Vector "b" internal data length:', vectorB.data[0].values.length);
The output is:
Table rows: 3
Length of "a": 3
Length of "b": 3
Vector "a" at index 3: undefined
Vector "b" at index 3: 0
Vector "a" at index 100: undefined
Vector "b" at index 100: undefined
Vector "a" internal data length: 3
Vector "b" internal data length: 8
I would expect "b" to also return undefined for elements outside of its length. Instead it returns zero.
I noticed that the internal length of the Float64Array is 8 instead of 3, I suspect this has something to do with it?
Here's an online playground that shows the issue:
https://stackblitz.com/edit/vitejs-vite-9k7gaz?file=main.js
Component(s)
JavaScript
- Dominant language
- TypeScript
- Stars
- 112
- Forks
- 23
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/arrow-js
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 50/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
TanStack/tanstack.com#1293 ·