rdblue commented on a change in pull request #3988:
URL: https://github.com/apache/iceberg/pull/3988#discussion_r800242361
##########
File path: python_legacy/tests/api/test_conversions.py
##########
@@ -79,3 +87,9 @@ def test_to_bytes(self):
Literal.of(uuid.UUID("f79c3e09-677c-4bbd-a479-3f349cb785e7")).to_byte_buffer())
self.assertEqual(b'foo', Literal.of(bytes(b'foo')).to_byte_buffer())
self.assertEqual(b'foo',
Literal.of(bytearray(b'foo')).to_byte_buffer())
+ # Decimal on 2-bytes
+ self.assertEqual(b'\x30\x39', Literal.of(123.45).to(DecimalType.of(5,
2)).to_byte_buffer())
+ # Decimal on 3-bytes to test that we use the minimum number of bytes
+ self.assertEqual(b'\x12\xd6\x87',
Literal.of(123.4567).to(DecimalType.of(7, 4)).to_byte_buffer())
+ # Negative decimal to test two's complement
+ self.assertEqual(b'\xed\x29\x79',
Literal.of(-123.4567).to(DecimalType.of(7, 4)).to_byte_buffer())
Review comment:
Can you make sure the test cases are shared between the Java
implementation and here? There's a test for Java in `TestConversions` but it
would be good to add these cases and ensure that they match. I'd also like to
have a case that requires an empty byte, like
`Literal.of(0.11).to(DecimalType.of(10, 2)).to_byte_buffer()`, as well as one
for negative numbers.
--
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]