v.20.8New Feature

Add countDigits and isDecimalOverflow functions to ClickHouse

Add countDigits(x) function that count number of decimal digits in integer or decimal column. Add isDecimalOverflow(d, [p]) function that checks if the value in Decimal column is out of its (or specified) precision. #14151 (Artem Zuikov).
Introduced two new functions: countDigits(x) to count the number of decimal digits in integer or decimal columns, and isDecimalOverflow(d, [p]) to check if a value in a Decimal column exceeds its defined or specified precision.

Why it matters

These functions help users to analyze and validate numeric data by accurately counting digits and detecting decimal overflow errors. This enhances data quality checks and simplifies handling of precision issues in decimal columns.

How to use it

Use countDigits(x) by passing an integer or decimal column to return the count of decimal digits. Use isDecimalOverflow(d, [p]) by passing a Decimal column and optionally a precision value p to determine if the value exceeds that precision, returning a boolean result.