ghdna / athena-express

Athena-Express can simplify executing SQL queries in Amazon Athena AND fetching cleaned-up JSON results in the same synchronous or asynchronous request - well suited for web applications.
https://www.npmjs.com/package/athena-express
MIT License
179 stars 70 forks source link

Datatype 'bigint' is not handled #79

Closed AndreasNeuwirth closed 2 years ago

AndreasNeuwirth commented 2 years ago

When the result of a query is converted to Json, columns with datatype bigint are converted to a string instead of to a number because the specific case is missing (https://github.com/ghdna/athena-express/blob/master/lib/helpers.js#L224).

ghdna commented 2 years ago

Updated. Do note that now bigint will be denoted by a trailing n as per the MDN definition of big int

AndreasNeuwirth commented 2 years ago

Sorry, it seams I was a bit unclear, I expected it to be cast to a Number like the other int variants.

ghdna commented 2 years ago

Bigint and Number are two separate primitives. Bigint represents values, which are too large to be represented by the number primitive. Hence, if you force cast Bigint as Number, you can lose the precision of a BigInt value. Per the official documentation on Bigint

AndreasNeuwirth commented 2 years ago

Ah, thanks, should have read the docs more carefully (haven't seen bigint as js type before, to be honest).

ghdna commented 2 years ago

That's why I had left it as string. But now Athena-express correctly represents it as type Bigint. The trailing 'n' can seem awkward but its the accurate denotation of bigint.