Class ToDecfloat

java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.scalar.conversion.ToDecfloat

public class ToDecfloat extends BuiltInFunction
TO_DECFLOAT(expr [, format]) — a 38-digit decimal float on the account, carried here as a DOUBLE, the engine's stand-in for DECFLOAT (a DECFLOAT column is one too). It is not TO_DOUBLE: it takes a BOOLEAN, where TO_DOUBLE(TRUE) is refused while the statement compiles, and words its own failures (all live-verified):
   TO_DECFLOAT(TRUE)                    1           TO_DECFLOAT(FALSE)   0
   TO_DECFLOAT(' 1.5 ')                 1.5         the text is trimmed
   TO_DECFLOAT('abc')                   Numeric value 'abc' is not recognized   '', 'NaN' and 'inf' alike
   TO_DECFLOAT('1,234.5', '9,999.9')    1234.5      a format over a text source
   TO_DECFLOAT('123', '99')             Can't parse '123' as number with format '99'   the model's width
   TO_DECFLOAT('1e5', '9e9')            Bad input format model '9e9' for DECFLOAT: invalid numeric format
                                        keyword: 'e9'                                   see NumericFormatModel
   TO_DECFLOAT(PARSE_JSON('"1.5"'))     1.5         a VARIANT's number, boolean or numeric text
   TO_DECFLOAT(PARSE_JSON('[1]'))       Failed to cast variant value [1] to DECFLOAT
   TO_DECFLOAT(TO_VARIANT(1.5::FLOAT))  DecFloat not supported                  a VARIANT's DOUBLE
   TO_DECFLOAT(1e308::FLOAT * 10)       Decfloat out of representable range, operation: TO_DECFLOAT(inf)
 

A DATE, TIME, TIMESTAMP, BINARY, OBJECT or ARRAY source is refused while the statement compiles, the conversion sentence naming 'TO_DECFLOAT', and a format beside a source that is no text is too many arguments; neither reaches a row.

  • Constructor Details

    • ToDecfloat

      public ToDecfloat()
  • Method Details

    • evaluate

      public Object evaluate(List<Object> args)
      Description copied from class: BuiltInFunction
      Computes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Java null, and returning null makes the SQL result NULL.
      Specified by:
      evaluate in class BuiltInFunction
      Parameters:
      args - the argument values, in call order
      Returns:
      the function's value for these arguments, or null for SQL NULL
    • getMinArgCount

      public int getMinArgCount()
      Description copied from class: BuiltInFunction
      The fewest arguments a call to this function may pass; fewer is an argument-count error.
      Specified by:
      getMinArgCount in class BuiltInFunction
      Returns:
      the minimum accepted argument count
    • getMaxArgCount

      public int getMaxArgCount()
      Description copied from class: BuiltInFunction
      The most arguments a call to this function may pass; Integer.MAX_VALUE marks a variadic function (see BuiltInFunction.isVariadic()).
      Specified by:
      getMaxArgCount in class BuiltInFunction
      Returns:
      the maximum accepted argument count