rdblue commented on a change in pull request #3988:
URL: https://github.com/apache/iceberg/pull/3988#discussion_r800242408
##########
File path: python_legacy/iceberg/api/types/type_util.py
##########
@@ -105,6 +106,14 @@ def assign_fresh_ids(type_var, next_id):
.as_nested_type().fields))
+def decimal_to_bytes(_, value):
+ scale = abs(value.as_tuple().exponent)
+ quantized_value = value.quantize(Decimal("10")**-scale)
+ unscaled_value = int((quantized_value * 10**scale).to_integral_value())
+ min_num_bytes = (unscaled_value.bit_length() + 7) // 8
+ return unscaled_value.to_bytes(min_num_bytes, 'big', signed=True)
Review comment:
This implementation seems fine to me, but I'd really like to have tests
in sync between Java and Python to ensure it is correct.
--
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]