Add scalar function MIN_SCALE

Details

Detail name Value
Changelog Number 10912
Type New Feature
Status Resolved
Fix Versions Exasol 7.1.0, Exasol 7.1.alpha1
Resolution Date 2020-11-09

Description

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).

For example:

SELECT MIN_SCALE(123.00000) S1,
       MIN_SCALE(9.99999999999) S2,
       MIN_SCALE(-0.0045600) S3;

will give the results

S1    S2    S3   
----- ----- -----
    0    11     5

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:

select max(ms) from (select min_scale(x) ms from t);

If the maximum scale does not match the column definition, you can adjust the scale.

Changed behavior

Added MIN_SCALE(), a new scalar function.