Skip to content

Conversation

@wendigo
Copy link
Contributor

@wendigo wendigo commented Nov 27, 2025

Description

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

@wendigo
Copy link
Contributor Author

wendigo commented Nov 28, 2025

Before I start adding tests and whatnot, let's agree on naming first.

@martint can you take a look?

@Constraint(variable = "u", expression = "min(u, 6)")
public static Slice uuid_v6(@SqlType("timestamp(u) with time zone") long rawTimestamp)
{
java.util.UUID uuid = V6_GENERATOR.construct(rawTimestamp);
Copy link
Member

Choose a reason for hiding this comment

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

I doubt com.fasterxml.uuid.impl.TimeBasedEpochRandomGenerator knows the structure of trino timestamp tz values

Comment on lines +68 to +69
@Constraint(variable = "u", expression = "min(u, 6)")
public static Slice uuid_v6(@SqlType("timestamp(u) with time zone") long rawTimestamp)
Copy link
Member

Choose a reason for hiding this comment

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

That results in a rather nasty exception

trino> select uuid_v6( current_timestamp(9) );
Query 20251128_140821_00027_837vf failed: variable 'u' is already set to 9 when trying to set 6
java.lang.IllegalStateException: variable 'u' is already set to 9 when trying to set 6

Engine is not supposed to throw anything other than TrinoExceptions.

Comment on lines +64 to +65
@Description("Generates a random UUID v6 from a given timestamp (RFC-9562)")
@ScalarFunction
Copy link
Member

Choose a reason for hiding this comment

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

Provide explicit deterministic declaration.

Copy link
Member

Choose a reason for hiding this comment

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

BTW this function looks deterministic. What's the use-case to have it?

public static Slice uuid()
{
java.util.UUID uuid = randomUUID();
java.util.UUID uuid = V4_GENERATOR.generate();
Copy link
Member

Choose a reason for hiding this comment

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

Is this better, different, or same as randomUUID the code used to use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants