You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "wjones127 (via GitHub)" <gi...@apache.org> on 2024/02/12 17:26:51 UTC

[I] [JS] `vectorFromArray()` can't create Int64 from Number [arrow]

wjones127 opened a new issue, #40051:
URL: https://github.com/apache/arrow/issues/40051

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   
   ```js
   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


-- 
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: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org