Generate and work with Universally Unique Identifiers.
expr
(any type, optional): An optional expression used to bypass common subexpression elimination if the function is called multiple times in a query. The value of the expression does not affect the returned UUID.UUID
.
Example:
expr
(any type, optional): An arbitrary expression used to bypass common subexpression elimination if the function is called multiple times in a query. The value of the expression does not affect the returned UUID.UUIDv7
.
Description:
The generated UUIDv7 contains the following components:
UUID
(UUID
): A UUID value.UInt8
]UUID
(UUID
): A UUID value.1
for a non-empty UUID or 0
for an empty UUID. [UInt8
]1
, indicating that the generated UUID is not empty.
Array
s and String
s.string
(String
): A string containing a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
.string
(String
) — A string containing a UUID.default
(UUID
) — The UUID to return if the conversion fails.toUUIDOrDefault
call successfully converts a valid UUID string.string
(String
): A string containing a UUID representation.UUID
)]
Example:
valid_uuid
successfully converts a valid UUID string.invalid_uuid
returns NULL for a completely invalid input.malformed_uuid
returns NULL for a UUID-like string with an extra character.string
(String
) — A string containing a UUID.UUID
]valid_uuid
successfully converts a valid UUID string.invalid_uuid
returns a zero UUID for an invalid input.taco_uuid
also returns a zero UUID, as “spicy-carnitas-taco” is not a valid UUID format.uuid
(String
): A string containing a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
.variant
(UInt8
, optional): Integer specifying the byte order variant.
FixedString(16)
)
Example:
binary
(FixedString(16)
): A binary representation of a UUID.variant
(UInt8
, optional): Integer specifying the UUID format variant.
String
)
Example:
UUIDNumToString
converts the binary representation of a UUID to its string format. The second example demonstrates using the Microsoft variant.
This function is particularly useful when you need to convert UUID values stored in binary format back to their human-readable string representation, such as when working with UUIDs in taco order systems or customer databases.
uuid
(UUID
): Value of type UUID.variant
(UInt8
, optional): Integer representing the byte order variant.
FixedString(16)
containing the binary representation of the UUID.uuid
(UUID
): UUID of version 7.timezone
(String
, optional): Timezone name for the returned value.DateTime64(3)
]