Class SeqFn
One class for all four because they differ only in that width: the digit in the name is the number of BYTES, so SEQ1 counts in 8 bits and SEQ8 in 64. Measured live:
SEQ1() NUMBER(3,0) SEQ2() NUMBER(5,0) SEQ4() NUMBER(10,0) SEQ8() NUMBER(19,0)
The optional argument is a SIGN, 0 or 1, and it decides what happens at the top of the range rather than where counting starts — every form starts at 0. With the default 0 the count stays non-negative and wraps at the signed maximum; with 1 it wraps the way a two's-complement integer of that width does. Measured over 260 rows for SEQ1 and 70000 for SEQ2:
SEQ1() … 125 126 127 0 1 … SEQ1(1) … 125 126 127 -128 -127 … SEQ2() … 32766 32767 0 1 … SEQ2(1) … 32766 32767 -32768 -32767 … SEQ2() min 0 max 32767, 32768 values SEQ2(1) min -32768 max 32767, 65536 values
The sign does NOT change the declared type: SEQ1(1) is still NUMBER(3,0), wide enough
for -128 either way.
Frostlake is contiguous where Snowflake only promises to be distinct. Live, the values come from whatever unit of parallelism produced the row: over a 16-row join the account returned 16 rows numbered between 7 and 127, not 0..15, which is why Snowflake's own documentation says not to use SEQ as a key generator and to reach for ROW_NUMBER instead. That artefact is not reproducible — it is not even stable run to run — so Frostlake numbers rows 0, 1, 2, … in the order the operator produces them. Every single-source shape agrees with live; a query that depends on the gaps is depending on something Snowflake does not promise.
-
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
-
Constructor Details
-
SeqFn
- Parameters:
name- the Snowflake spelling, whose trailing digit isbytesbytes- the width in bytes: 1, 2, 4 or 8
-
-
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
-