zeroshade commented on code in PR #1130:
URL: https://github.com/apache/iceberg-go/pull/1130#discussion_r3305399537
##########
table/substrait/substrait.go:
##########
@@ -273,13 +273,45 @@ func toDecimalLiteral(typ iceberg.Type, v
iceberg.DecimalLiteral) expr.Literal {
byts, _ := v.MarshalBinary()
result, _ := expr.NewLiteral(&types.Decimal{
Scale: int32(v.Scale),
- Value: byts,
+ Value: decimalBytesBEMinToLE16(byts),
Precision: int32(precision),
}, false)
Review Comment:
Instead of doing the `MarshalBinary`, if we're running on a LE machine, then
you can just do `unsafe.Slice((*byte)(unsafe.Pointer(&v.Value().Val)), 16)` or
something to that end.
`DecimalLiteral.Value()` returns a `Decimal` and the `.Val` member is an
`Decimal128` which is represented by a struct consisting of two uint64s in
two's complement. So treating the struct as just the 16 bytes that make it up
would be the full 16 byte, little-endian, 2's complement representation. Nice
and simple :smile:
For big-endian, we just reverse the bytes, might be simpler than the
function you created below.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]