v.21.11New Features

Added accurateCastOrDefault function and resolved issue #21330

Added function accurateCastOrDefault(x, T). Closes #21330. Authors @taiyang-li. #23028 (Maksim Kita).
Introduces the function accurateCastOrDefault(x, T) to perform precise type casting in ClickHouse with a fallback default value.

Why it matters

This feature addresses the need for safer and more accurate type conversions by allowing users to cast a value x to a target type T and return a default value if the cast fails, preventing query errors and improving robustness.

How to use it

Use the function in your queries as accurateCastOrDefault(x, T), where x is the value to cast and T is the target data type. This will attempt to cast x to type T and return a default value on failure.