Open aditi-pandit opened 1 month ago
@mbasmanova @amitkdutta @tdcmeehan
Cc @kgpai @kagamiori
The fix could be in the PrestoSerializer/Deserializer for UUID to use the byte-ordering needed by the Presto Java side. Prototyping a fix.
I wonder if this is a correctness bug, since the encodings of UUIDs are a well-defined format: https://datatracker.ietf.org/doc/html/rfc9562. i.e. if anyone relies on comparing on persisted UUIDs, this might be incorrect since it seems the byte order is revered on either the Java or C++ side?
Hi @mohsaka , please let me know if there was anything I could help out with this issue, thanks.
Hi @BryanCutler Feel free to take over the issue. I am not actively working on it.
So I think the underlying issue is actually with HUGEINT in presto that was never discovered since HUGEINT isn't a type in presto.
@BryanCutler Pointed out that its actually not reversed but rather reversed and swapped 64 bit words.
The main issue is that the HUGEINT type in presto is represented by an array of longs in the form of [MSW, LSW]. However in Velox, we store it in the form of Little Endian, [LSW,MSW].
Therefore when we send it over to presto, we are sending it over as an array of two longs or 64 bit words. Which means [LSW,MSW]. Then the serializer takes into account the endian reversal which results in us having [Reversed LSW, Reversed MSW].
So I recommended that he fix the HUGEINT issue first, then fix the reversal issue by putting the proper HUGEINT decimal value in so that when the endian is flipped we get the proper value in Java presto.
Queries with UUID have different results in Java vs Native
Your Environment
Expected Behavior
UUIDs are typically stored as VARCHAR or VARBINARY values in HMS/DWRF/Parquet etc. They are cast as UUID in subsequent SQL.
Presto Java uses Java UUID to represent UUID, whereas the block representation for native is int128. When getting results from presto-cli the order of bytes is flipped. This leads to misrepresentations.
Steps to Reproduce