The current version of UUID provides a random identifier (verion 4).
However, certain situations requires a more stable uuid (i,e version 5 or 3). Advantage with these UUIDs (v5 or v3) is that they have the property that the same namespace and name will map to the same UUID.
Its possible to have a facsimile (see example below) of uud5 but requires a awkward hand-crafted udf. It might be more convenient if it were a first class function instead.
Here is an example in snowflake that overloads uuid_string to provide either version 4 or 5
Thanks for your consideration and hard work
Contrast how uuid5 is namespace aware (and idempotent) compared to existing uuid function
trino> select substr(to_hex(sha256(from_base64url('this_is_a_my_namespace'||'__'||'my_actual_variable'))), 1, 32) as fake_uuid_5, uuid() as current_uuid;
fake_uuid_5 | current_uuid
----------------------------------+--------------------------------------
C5871659322001D2B21C2A65069F0A6D | 344d8ea9-eaca-42a6-88d8-7a8ad2509bde
trino> select substr(to_hex(sha256(from_base64url('this_is_a_my_namespace'||'__'||'my_actual_variable'))), 1, 32) as fake_uuid_5, uuid() as current_uuid;
fake_uuid_5 | current_uuid
----------------------------------+--------------------------------------
C5871659322001D2B21C2A65069F0A6D | bb9a41af-9597-43e7-926a-40291e64ca24
The current version of UUID provides a random identifier (verion 4).
However, certain situations requires a more stable uuid (i,e version 5 or 3). Advantage with these UUIDs (v5 or v3) is that they have the property that the same namespace and name will map to the same UUID.
Its possible to have a facsimile (see example below) of uud5 but requires a awkward hand-crafted udf. It might be more convenient if it were a first class function instead.
Here is an example in snowflake that overloads
uuid_string
to provide either version 4 or 5Thanks for your consideration and hard work
Contrast how uuid5 is namespace aware (and idempotent) compared to existing
uuid
function