v.22.11New Feature

Add pmod function for non-negative modulo results

Add function pmod which returns non-negative result based on modulo. #42755 (李扬).
Added the pmod function that returns a non-negative result for modulo operations.

Why it matters

The pmod 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 the pmod function in your queries like any other function. For example:

SELECT pmod(-5, 3);

This will return 1 instead of a negative value.