Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UUID ordering tests #12913

Merged
merged 2 commits into from
Jun 21, 2022
Merged

Add UUID ordering tests #12913

merged 2 commits into from
Jun 21, 2022

Conversation

findepi
Copy link
Member

@findepi findepi commented Jun 20, 2022

No description provided.

UUID is stored as two big-endian numbers, so incrementing the value
should take this into account.
@findepi findepi added test no-release-notes This pull request does not require release notes entry labels Jun 20, 2022
@findepi findepi requested review from electrum, martint and homar June 20, 2022 20:42
@findepi findepi mentioned this pull request Jun 20, 2022
@cla-bot cla-bot bot added the cla-signed label Jun 20, 2022
java.util.UUID lower = java.util.UUID.fromString(lowerAsString);
java.util.UUID higher = java.util.UUID.fromString(higherAsString);
// Java UUID's comparison is not consitent with RFC 4122, see https://bugs.openjdk.org/browse/JDK-7025832
assertThat(higher).isLessThan(lower);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of testing the JDK implementation of isLessThan? I don't see anything below that relies on this behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose was to show and document acknowledgement to the fact that JDK UUID behaves differently than our implementation, and also to anchor the explanation, if someone would wonder in the future who's right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't use Java UUIDs for ordering, so how is that behavior relevant? If anything, such documentation should be added to the UUID type class so that anyone using it in their connector is aware. This comment is going to be largely invisible for that purpose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't use Java UUIDs for ordering

we use it in H2QueryRunner (implicitly)
and in Iceberg library (implicitly, apparently)

such documentation should be added to the UUID type class so that anyone using it in their connector is aware

This isn't supposed to be consumer facing documentation.
It's supposed to capture information for future Trino maintainers, including future myself

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we have javaUuidToTrinoUuid/trinoUuidToJavaUuid public methods in UuidType, that information seems relevant for anyone manipulating UUIDs, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that there can be some other place where the information would be useful too.
it doesn't make it unnecessary in the uuid ordering test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As somebody who tends to look at unit tests quite often when getting an understanding of things, I do appreciate this form of documentation for something a bit... quirky / not intuitively obvious when looking at the UUID type class directly.

This could possibly be documented elsewhere as mentioned, but I agree with @findepi that it has utility as a unit test. Particularly, the rest of the test seems to testing that two Trino UUID's are comparable as well as how to do it. If I were working on a feature (say for the Iceberg connector), this is amongst the first places I would likely go for looking at using the code.

If this isn't going to be user facing documentation, then I think this comparison test for the JDK UUIDs is beneficial. Though a comment in UuidType would also suffice for me - but that's more up to you guys. I think the rest of the test is beneficial though.

@findepi findepi requested a review from martint June 21, 2022 14:35
@findepi findepi merged commit bb163dd into trinodb:master Jun 21, 2022
@findepi findepi deleted the findepi/uuid branch June 21, 2022 20:47
@github-actions github-actions bot added this to the 387 milestone Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed no-release-notes This pull request does not require release notes entry test
Development

Successfully merging this pull request may close these issues.

4 participants