v.22.11New Feature
Add pmod function for non-negative modulo results
Add function pmod which returns non-negative result based on modulo. #42755 (李扬).Why it matters
Thepmod function addresses the issue of modulo operations returning negative results when the dividend is negative. It ensures the result is always non-negative, which is useful for consistent, predictable calculations and data transformations.How to use it
Use thepmod function in your queries like any other function. For example:SELECT pmod(-5, 3);This will return
1 instead of a negative value.