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


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

Posted by "trxcllnt (via GitHub)" <gi...@apache.org>.
trxcllnt commented on issue #40051:
URL: https://github.com/apache/arrow/issues/40051#issuecomment-2749720094

   The value is assigned to a `BigInt64Array()`, so the error you're seeing is just what happens when you don't use BigInts:
   ```shell
   $ node -p 'new BigInt64Array([1])'
   [eval]:1
   new BigInt64Array([1])
   ^
   
   TypeError: Cannot convert 1 to a BigInt
       at new BigInt64Array (<anonymous>)
       at [eval]:1:1
       at runScriptInThisContext (node:internal/vm:209:10)
       at node:internal/process/execution:118:14
       at [eval]-wrapper:6:24
       at runScript (node:internal/process/execution:101:62)
       at evalScript (node:internal/process/execution:136:3)
       at node:internal/main/eval_string:51:3
   
   Node.js v22.4.0
   
   $ node -p 'new BigInt64Array([1n])'
   BigInt64Array(1) [ 1n ]
   ```


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

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