Uploaded image for project: 'EXASOL Roadmap'
  1. EXASOL Roadmap
  2. EXASOL-2776

Add scalar function MIN_SCALE

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Component/s: None
    • Labels:
      None
    • Changed Behavior:
      Added MIN_SCALE(), a new scalar function.

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            CaptainEXA Captain EXASOL
            Reporter:
            CaptainEXA Captain EXASOL
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: