v.25.5New Feature

Add functions divideOrNull,moduloOrNull, intDivOrNull,positiveModuloOrNull

Add functions divideOrNull,moduloOrNull, intDivOrNull,positiveModuloOrNull to return NULL when right argument is zero. #78276 (kevinyhzou).
Added nullable-safe arithmetic functions <code>divideOrNull</code>, <code>moduloOrNull</code>, <code>intDivOrNull</code>, and <code>positiveModuloOrNull</code> that return NULL when the right argument is zero.

Why it matters

These functions address the problem of division and modulo operations by zero, which typically cause errors or exceptions. By returning NULL instead, they provide safer handling of such cases and prevent query failures, improving robustness in analytics and data processing.

How to use it

Use these functions in place of their non-nullable counterparts in your queries. For example:

SELECT divideOrNull(numerator, denominator) FROM table

They will return NULL instead of failing when the denominator is zero.