v.21.9Improvement

Add _CAST Function with Modified Nullability Preservation Rules

Add _CAST function for internal usage, which will not preserve type nullability, but non-internal cast will preserve according to setting cast_keep_nullable. Closes #12636. #27382 (Kseniia Sumarokova).
Introduced an internal _CAST function that performs type casting without preserving the nullability of types, unlike the non-internal CAST which respects the cast_keep_nullable setting.

Why it matters

This feature addresses the need for an internal casting mechanism that ignores type nullability preservation to enable more flexible and predictable type conversions within ClickHouse internals. It solves inconsistencies related to nullability handling during casts and improves internal operation stability.

How to use it

The _CAST function is intended for internal use only and does not require user configuration. Users can continue to use the standard CAST function, which preserves nullability based on the cast_keep_nullable setting. No changes are necessary for regular usage.