v.20.11New Feature

Added toUUIDOrNull and toUUIDOrZero Cast Functions

Added toUUIDOrNull, toUUIDOrZero cast functions. #16337 (Maksim Kita).
Added new cast functions toUUIDOrNull and toUUIDOrZero for converting values to UUIDs with fallback options.

Why it matters

These functions provide safer type casting by returning NULL or a zero UUID instead of throwing an error when conversion to UUID fails. This improves data processing robustness and simplifies error handling in queries involving UUID conversions.

How to use it

Use the functions in your SQL queries like this:

SELECT toUUIDOrNull(column) FROM table;
SELECT toUUIDOrZero(column) FROM table;

They attempt to cast input to UUID and return NULL or a zero UUID respectively if conversion is not possible.