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

public class ToChar extends BuiltInFunction
  • Constructor Details

    • ToChar

      public ToChar()
  • Method Details

    • structuredRejection

      public SemiStructuredRejection structuredRejection(int position)
      A plain OBJECT or ARRAY renders to its JSON text; a STRUCTURED value has no text conversion at all. Live, TO_VARCHAR(o) is {"k":"v1"} and TO_CHAR(a) is [1,2], while TO_VARCHAR(so) is "invalid type [TO_VARCHAR(ST.SO)] for parameter 'TO_VARCHAR'" and TO_CHAR(so) the same sentence for 'TO_CHAR' — the parameter named is the name as WRITTEN, which is why one registered object serves both spellings. All three structured kinds refuse alike, and the CAST spellings of the same conversion are rejected by their own rule since they are not function calls.

      Position 0 only: TO_VARCHAR(so, 'x') does fail live, but it fails for the ARGUMENT, naming the whole call — nothing has been measured about a structured value in the FORMAT position.

      Overrides:
      structuredRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the extra refusal this position gives a structured value, or NONE when undeclared
    • vectorRejection

      public SemiStructuredRejection vectorRejection(int position)
      A VECTOR has no text conversion, and the refusal is the SAME sentence a structured value gets — live quotes the whole call and names the conversion the written spelling routes through, so TO_CHAR(v) reports 'TO_CHAR' where TO_VARCHAR(v) reports 'TO_VARCHAR'.

      Position 0 only, and the ARGUMENT beats the ARITY: live gives TO_VARCHAR(v, 'x') this same refusal rather than complaining about the format argument, echoing the format in the quoted call.

      Overrides:
      vectorRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the refusal this position gives a VECTOR value; by default none
    • 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