Class WidthBucket
java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.NumericArgumentFunction
dev.frostlake.functions.scalar.math.WidthBucket
WIDTH_BUCKET(value, min, max, count) — which of
count equal buckets between min and
max the value falls in, 0 below the range and count + 1 above it.
A REVERSED range is legal and buckets downwards: over (10, 0, 5) the buckets are
(8,10], (6,8] … and the two out-of-range answers swap places, so a value above
min is 0 and one at or below max is count + 1. Frostlake answered 0 for
every reversed call, since it only ever compared the value against the arguments in the order they
were written.
A bucket count that is not positive, and a range whose ends are EQUAL, are the same refusal, and it names all three numbers — with the two bounds printed as UNSCALED integers at the widest scale among the value and the bounds, which is how Snowflake holds them:
WIDTH_BUCKET(<NUMBER(10,2)>, 0, 10, 0) … 0 (min_value) != 1000 (max_value) WIDTH_BUCKET(<NUMBER(38,0)>, 0, 10, 0) … 0 (min_value) != 10 (max_value) WIDTH_BUCKET(<NUMBER(10,2)>, 0.5, 10.5, 0) … 50 (min_value) != 1050 (max_value)
Any NULL argument makes the answer NULL, the bucket count included.
-
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.NumericArgumentFunction
binaryRejection, booleanRejection, semiStructuredRejection, temporalRejection, vectorRejectionMethods inherited from class dev.frostlake.functions.BuiltInFunction
approximateRejection, evaluate, fileRejection, geoRejection, getName, getReturnType, isVariadic, refusesMissingArgumentsByType, structuredRejection, temporalRejection, temporalRejection, textRejection, uuidRejection
-
Constructor Details
-
WidthBucket
public WidthBucket()
-
-
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
-