v.24.5New Feature

Added SQL Functions for UUID Version 7 and Extraction Methods

Added a new SQL function generateUUIDv7 to generate version 7 UUIDs aka. timestamp-based UUIDs with random component. Also added a new function UUIDToNum to extract bytes from a UUID and a new function UUIDv7ToDateTime to extract timestamp component from a UUID version 7. #62852 (Alexey Petrunyaka).
Introduces a new SQL function generateUUIDv7 to generate version 7 UUIDs, which are timestamp-based UUIDs with a random component. Additionally, it adds UUIDToNum for extracting bytes from a UUID and UUIDv7ToDateTime for retrieving the timestamp from a UUIDv7.

Why it matters

This feature provides support for version 7 UUIDs that combine a timestamp with randomness, enabling better sorting and time extraction capabilities. It addresses the need for UUIDs that are both unique and time-ordered, enhancing data organization and time-based querying in ClickHouse.

How to use it

Use the function generateUUIDv7() in your SQL queries to create version 7 UUIDs. To extract the raw numeric bytes of any UUID, use UUIDToNum(uuid). To obtain the datetime from a version 7 UUID, use UUIDv7ToDateTime(uuidv7).