Class VectorTrunc

java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.scalar.vector.VectorTrunc

public class VectorTrunc extends BuiltInFunction
VECTOR_TRUNC(v, n) (alias VECTOR_TRUNCATE) — the vector's FIRST n dimensions, keeping the element type.

Live-verified: VECTOR_TRUNC([1,2,3]::VECTOR(FLOAT,3), 2) is [1.0,2.0] with SYSTEM$TYPEOF VECTOR(FLOAT, 2), the INT vector truncates to [1,2] / VECTOR(INT, 2), n = 0 is the empty [], n equal to the dimension is the unchanged vector, and a typed NULL vector yields NULL. n is a COMPILE-time constant that may not exceed the source dimension — n = 9 over a 3-vector is "Requested truncation dimension 9 for VECTOR_TRUNC should be less than or equal to the dimension of the provided vector (3).", and a column / an expression / a non-integral literal are all "needs to be constant". Those checks live in the expression layer, where the STATIC types are known.

A dimension of -1 is the one negative the account compiles: the statement is accepted, over an empty table it answers no rows, and each row it does read fails with the account's internal error, the incident number that sentence carries on the account being left out here.

  • Field Details

    • ROW_FAILING_DIMENSION

      public static final int ROW_FAILING_DIMENSION
      The negative dimension that compiles and then fails on every row it is asked of.
      See Also:
  • Constructor Details

    • VectorTrunc

      public VectorTrunc()
  • 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