Skip to content

DuckDB window function returns tuple instead of value #1713

Answered by mbostock
angrytongan asked this question in Q&A
Discussion options

You must be logged in to vote

Yep, this is how Apache Arrow represents large integers. A trivial reproduction of this is:

```sql id=[{n}]
SELECT 11111111100::INT128 AS n
```

This defines n as a Arrow.util.BN instance in the same fashion as if you had written:

const n = new Arrow.util.BN(new Uint16Array([0x19bc, 0x9646, 0x0002, 0, 0, 0, 0, 0]));

In order to work with this value as a number, you’ll need to cast it to a number. You can do that in JavaScript as:

Number(n)

You can also implicitly cast it to a number e.g. as +n.

Alternatively, if you want a bigint, you can go through a string (unfortunately it does not appear that you can coerce directly to BigInt with the current version of Apache Arrow):

BigInt(String(n))

I…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@mythmon
Comment options

@df-rw
Comment options

Comment options

You must be logged in to vote
1 reply
@df-rw
Comment options

Answer selected by mbostock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1712 on October 02, 2024 08:42.