Open jheer opened 1 year ago
Whats the status on this? Thanks!
Working with actual decimals (not ints - looks v broken, ex. decimal(38,9))
Converting from 64 and 128-bit decimals to 64-bit floats isn't implemented yet. I don't have the bandwidth to do it currently, but PR's are welcome. libcudf's C++ implementation would be a great starting point: https://github.com/rapidsai/cudf/blob/branch-24.04/cpp/include/cudf/fixed_point/fixed_point.hpp
I wrote our own converter for Mosaic if it helps: https://github.com/uwdata/mosaic/blob/main/packages/core/src/util/convert-arrow.js#L132
Thanks guys, we wrote our own yesterday too. Will push a PR shortly. Looks like theres a bug in your code too @jheer will update soon.
We just ran into this using DuckDB-Wasm. Here’s a simple query that demonstrates the problem:
SELECT 11111111100::INT128 AS n
This returns a DecimalBigNum consisting of
[2521176508, 2, 0, 0]
And likewise string coercion returns the expected "11111111100"
, but number coercion gives 4.460189873590169e+44
.
https://github.com/apache/arrow/pull/40729 starts to fix decimal support. More to come.
The next step is to automatically apply the scaling of the type when one calls get
on an arrow vector. We probably want to create a new BigNum type and refactor what we have in that file (some of it is left over from before BigInt was widely available in js).
Describe the bug, including details regarding any error messages, version, and platform.
Thanks for all the work on Arrow! Unfortunately, I've run into problems in the JS API around both encoding and decoding of Decimal-typed data.
Encoding:
Results in
TypeError: d.subarray is not a function
(Incidentally it also seems that the Decimal type constructor uses a different argument order than pyarrow.)
Decoding:
Since encoding failed in JS, let's do it in pyarrow:
and then we can carry the resulting byte string over to JavaScript and try to decode it:
While the basic byte encoding looks OK, all of the built-in conversions appear to be faulty.
Related: #28804, #35745 cc: @domoritz
Component(s)
JavaScript