Skip to content

[JS] vectorFromArray() can't create Int64 from Number #66

Open
@wjones127

Description

@wjones127

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

const { vectorFromArray, Int64 } = require('apache-arrow');
vectorFromArray([1], new Int64())

Fails with

Uncaught TypeError: Cannot convert 1 to a BigInt
    at DataBufferBuilder.set (/Users/willjones/Downloads/repro2/node_modules/apache-arrow/builder/buffer.js:79:42)
    at Int64Builder.setValue (/Users/willjones/Downloads/repro2/node_modules/apache-arrow/builder/int.js:24:22)
    at Int64Builder.set (/Users/willjones/Downloads/repro2/node_modules/apache-arrow/builder.js:183:18)
    at Int64Builder.append (/Users/willjones/Downloads/repro2/node_modules/apache-arrow/builder.js:165:33)
    at /Users/willjones/Downloads/repro2/node_modules/apache-arrow/factories.js:183:25
    at Generator.next (<anonymous>)
    at vectorFromArray (/Users/willjones/Downloads/repro2/node_modules/apache-arrow/factories.js:52:55)

If we wrap in BigInt, it works:

> vectorFromArray([BigInt(1)], new Int64());
Vector [IntVector<Int>] {
  isValid: [Function (anonymous)],
  get: [Function (anonymous)],
  ...

This seems odd, as it seems like 1 is being converted internally to something that can't be converted into a BigInt. I would expect it to be preserved, unless I am misunderstanding how the conversion to BitInt is happening.

Component(s)

JavaScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't workingjavascriptPull requests that update javascript code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions