Class VectorFunctionHelper

java.lang.Object
dev.frostlake.functions.scalar.vector.VectorFunctionHelper

public final class VectorFunctionHelper extends Object
Argument handling shared by the VECTOR functions.

Snowflake decides these functions' legality from the STATIC types, so the argument checks fire at COMPILE time — Frostlake runs them in the expression layer's strict-argument walk (which sees the declared types) and this helper is the RUNTIME backstop for the cases static inference cannot reach: a derived column, a CTE column, a UDF parameter. Live those keep the vector type all the same — SELECT IS_VECTOR(v) FROM (SELECT [1,2,3]::VECTOR(FLOAT,3) AS v) is TRUE — which is why the runtime value carries its own element type and dimension.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    requireSameType(String funcName, List<Object> args, VectorValue left, VectorValue right)
    Both operands of a two-vector function must have the SAME element type and dimension — live, VECTOR_L2_DISTANCE(<VECTOR(FLOAT,3)>, <VECTOR(INT,3)>) and a 2-vs-3 dimension pair are both "Invalid argument types for function 'VECTOR_L2_DISTANCE': (…)".
    vectorArgument(String funcName, List<Object> args, int index)
    The argument as a vector, or null when the value is SQL NULL (every one of these functions is NULL-in / NULL-out: live, VECTOR_NORMALIZE(NULL::VECTOR(FLOAT,3)) and VECTOR_L2_DISTANCE(NULL::VECTOR(FLOAT,3), v) are both NULL).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • vectorArgument

      public static VectorValue vectorArgument(String funcName, List<Object> args, int index)
      The argument as a vector, or null when the value is SQL NULL (every one of these functions is NULL-in / NULL-out: live, VECTOR_NORMALIZE(NULL::VECTOR(FLOAT,3)) and VECTOR_L2_DISTANCE(NULL::VECTOR(FLOAT,3), v) are both NULL).
    • requireSameType

      public static void requireSameType(String funcName, List<Object> args, VectorValue left, VectorValue right)
      Both operands of a two-vector function must have the SAME element type and dimension — live, VECTOR_L2_DISTANCE(<VECTOR(FLOAT,3)>, <VECTOR(INT,3)>) and a 2-vs-3 dimension pair are both "Invalid argument types for function 'VECTOR_L2_DISTANCE': (…)".