v.25.5New Feature
Add functions divideOrNull,moduloOrNull, intDivOrNull,positiveModuloOrNull
Add functionsdivideOrNull,moduloOrNull,intDivOrNull,positiveModuloOrNullto return NULL when right argument is zero. #78276 (kevinyhzou).
Why it matters
These functions address the problem of division and modulo operations by zero, which typically cause errors or exceptions. By returningNULL 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 tableThey will return
NULL instead of failing when the denominator is zero.