Class VectorTrunc
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe negative dimension that compiles and then fails on every row it is asked of. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComputes the function's result over its already-evaluated argument values.intThe most arguments a call to this function may pass;Integer.MAX_VALUEmarks a variadic function (seeBuiltInFunction.isVariadic()).intThe fewest arguments a call to this function may pass; fewer is an argument-count error.Methods inherited from class dev.frostlake.functions.BuiltInFunction
approximateRejection, binaryRejection, booleanRejection, evaluate, fileRejection, geoRejection, getName, getReturnType, isVariadic, refusesMissingArgumentsByType, semiStructuredRejection, structuredRejection, temporalRejection, temporalRejection, temporalRejection, textRejection, uuidRejection, vectorRejection
-
Field Details
-
ROW_FAILING_DIMENSION
public static final int ROW_FAILING_DIMENSIONThe negative dimension that compiles and then fails on every row it is asked of.- See Also:
-
-
Constructor Details
-
VectorTrunc
public VectorTrunc()
-
-
Method Details
-
evaluate
Description copied from class:BuiltInFunctionComputes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Javanull, and returningnullmakes the SQL result NULL.- Specified by:
evaluatein classBuiltInFunction- Parameters:
args- the argument values, in call order- Returns:
- the function's value for these arguments, or
nullfor SQL NULL
-
getMinArgCount
public int getMinArgCount()Description copied from class:BuiltInFunctionThe fewest arguments a call to this function may pass; fewer is an argument-count error.- Specified by:
getMinArgCountin classBuiltInFunction- Returns:
- the minimum accepted argument count
-
getMaxArgCount
public int getMaxArgCount()Description copied from class:BuiltInFunctionThe most arguments a call to this function may pass;Integer.MAX_VALUEmarks a variadic function (seeBuiltInFunction.isVariadic()).- Specified by:
getMaxArgCountin classBuiltInFunction- Returns:
- the maximum accepted argument count
-