Closed TN1ck closed 2 years ago
Try https://github.com/xitongsys/parquet-go/blob/master/example/type.go#L96-L99, or you can post your code here.
Thanks @hangxie, that put me onto the right track to fix it. What I did wrong:
StrIntToBinary
you linked to put it into binarytypes.DECIMAL_BYTE_ARRAY_ToString(bytes, 0, scale)
to actually read the decimal value.One gotcha I had with DECIMAL_BYTE_ARRAY_ToString
was that I had to special case 0
as it won't change when scaled and DECIMAL_BYTE_ARRAY_ToString
doesn't handle that yet, negative values were also problematic as seen in your PR https://github.com/xitongsys/parquet-go/pull/433.
Would be nice is this would be documented somewhere, but I guess Decimal is still a bit WIP.
I close this for now as the problem is mostly ergonomics right now and not an explicit bug.
Hey all,
I'm currently trying to save numbers in the decimal file format and while reading/writing is working within parquet-go, problems surface when using other parquet readers, such as https://pypi.org/project/parquet-tools/, which is based upon the official apache java library.
When I saved my decimals using this annotation:
The schema is read correctly using another tool (for example with the linked the linked parquet-tools).
But the numbers do not match, up, when saving 100.00, this is the output:
I tried out different encodings, but the resulting value is the same. When using another storage format, i.e. FIXED_LEN_BYTES, the parquet-tools reader will crash:
Not sure if I'm doing something wrong or how I'm supposed to read these values using other readers.