Class IntegerResultWidths

java.lang.Object
dev.frostlake.types.IntegerResultWidths

public final class IntegerResultWidths extends Object
The declared PRECISION of the integer-returning functions, which is not one number. A NUMBER column is NUMBER(38,0) and so is anything derived arithmetically from it, but a function that returns a COUNT, a LENGTH, a POSITION or a DATE PART declares only as many digits as its result can occupy — and the account distinguishes five widths, every one of them measured here rather than reasoned:
   2   MONTH DAY DAYOFMONTH DAYOFWEEK DAYOFWEEKISO WEEK WEEKISO WEEKOFYEAR QUARTER
       HOUR MINUTE SECOND
   4   YEAR DAYOFYEAR YEAROFWEEK YEAROFWEEKISO ASCII JAROWINKLER_SIMILARITY
   9   CHARINDEX POSITION ARRAY_SIZE ARRAY_POSITION DATEDIFF TIMESTAMPDIFF EDITDISTANCE
   18  LENGTH LEN OCTET_LENGTH RTRIMMED_LENGTH UNICODE REGEXP_INSTR REGEXP_COUNT
       COUNT ROW_NUMBER RANK DENSE_RANK NTILE
   19  BIT_LENGTH HASH
   37  FACTORIAL
   38  BITAND BITOR BITXOR BITNOT BITSHIFTLEFT BITSHIFTRIGHT BITCOUNT GETBIT AS_INTEGER
 

The widths track what the value can BE — two digits for a month, nine for a position in a string, eighteen for a row count, nineteen for a signed 64-bit hash — but do not derive them from that story: DAYOFYEAR is four where DAYOFWEEK is two, BIT_LENGTH is nineteen where OCTET_LENGTH is eighteen, ASCII is four where UNICODE is eighteen though both name a code point, and FACTORIAL stops one digit short of the widest NUMBER. Measure the function, then add it.

This table is for functions whose width is a CONSTANT. The ones that derive it from their input — the rounding family, whose precision follows the argument's, and SIGN, which passes an approximate straight through — do not belong here.

  • Field Details

    • DATE_PART_SMALL

      public static final NumericType DATE_PART_SMALL
      A date part that cannot exceed two digits: a month, a day, an hour, a week, a quarter.
    • YEAR_PART

      public static final NumericType YEAR_PART
      A year, a day of the year, a year-of-week.
    • POSITION

      public static final NumericType POSITION
      A position within a string or array, and the difference between two temporals.
    • COUNTER

      public static final NumericType COUNTER
      A length, a count, a row number — the widest of the ordinary counters.
    • WIDE_COUNTER

      public static final NumericType WIDE_COUNTER
      A bit length or a hash, which need the extra digit a signed 64-bit value can reach.
    • FACTORIAL

      public static final NumericType FACTORIAL
      A factorial, which stops one digit short of the widest NUMBER.
    • WIDEST

      public static final NumericType WIDEST
      The widest NUMBER, which a difference counted in fractions of a second needs.