We have added a new scalar function, MIN_SCALE which returns the minimum scale needed to represent the argument exactly. This is equivalent to the number of fractional decimal digits in the value excluding trailing zeroes.
The argument must be an exact numeric (decimal).
will give the results
This can be useful to validate data types against the containing data. Assuming the column x is defined as DECIMAL(12,10), then you can run the below query to find the maximum scale of the data. For example:
If the maximum scale does not match the column definition, you can adjust the scale.