rzhang10 commented on code in PR #6004:
URL: https://github.com/apache/iceberg/pull/6004#discussion_r1005314331
##########
data/src/test/java/org/apache/iceberg/data/DataTestHelpers.java:
##########
@@ -88,6 +90,16 @@ private static void assertEquals(Type type, Object expected,
Object actual) {
"Primitive value should be equal to expected for type " + type,
expected, actual);
break;
case FIXED:
+ // For fixed type, Iceberg actually represent value as Bytebuffer,
+ // but since RandomGenericData generates bytearray data for fixed type
+ // for it to be written to Avro, we add a conversion here to make the
+ // equality comparison consistent using bytearray
+ if (expected instanceof ByteBuffer) {
+ expected = ByteBuffers.toByteArray((ByteBuffer) expected);
+ }
+ if (actual instanceof ByteBuffer) {
+ actual = ByteBuffers.toByteArray((ByteBuffer) actual);
Review Comment:
Yes, in `Type.java`, fixed type is associated with `ByteBuffe`:
```
FIXED(ByteBuffer.class),
```
So theoretically, fixed type data should always be `BtyeBuffer` type instead
of byte array.
And here the problem is actually the `RandomGenericData` generated the
`byte[]` data for fixed type ([I tried to change that
one](https://github.com/apache/iceberg/blob/8271791061e72dbf554028e477746e89fca9ec02/data/src/test/java/org/apache/iceberg/data/RandomGenericData.java#L236)
but it resulted in more tests failures because there are some existing avro
writers depending on it, and Avro can only write fixed type data represented by
`byte[]`).
So I instead added the conversion in this assertion helper class to convert
the ByteBuffer back to `byte[]` for compatible comparison.
--
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]