Class UdfParameterTypes

java.lang.Object
dev.frostlake.executor.expressions.UdfParameterTypes

public final class UdfParameterTypes extends Object
The type a SQL UDF's parameter carries INSIDE the body, which is not always the type it was declared with. The account types the body as if the call were inlined: a parameter takes the ARGUMENT's own static type wherever the argument needs no conversion to reach it, and the declared type only where it does. Live-measured, family by family:
  • a VARCHAR parameter takes a text argument's width, whatever it is — wider or narrower than the declaration — and the UNBOUNDED width for anything else, a number, a date and NULL alike;
  • a BINARY parameter takes a binary argument's width, and the declared one otherwise;
  • an exact NUMBER parameter takes an exact number argument's precision and scale only when that scale is at least the parameter's — 1.25 into NUMBER(10,2) stays NUMBER(3,2) while a bare 1 becomes NUMBER(10,2) — and the declared type for a FLOAT, a text or NULL;
  • every other family, FLOAT among them, keeps the declared type.
  • Method Details

    • effective

      public static DataType effective(DataType declared, DataType argument)
      The type the body reads this parameter at.
      Parameters:
      declared - the parameter's declared type
      argument - the argument's static type, or null when it could not be typed
      Returns:
      the type to compile the body with