Class RowOrdinal
SEQ1 / SEQ2 / SEQ4 / SEQ8 family reads.
The ordinal belongs to the ROW, not to the call. Measured live, two SEQ4() calls in one
row return the SAME number (SEQ4() + SEQ4() yields 0, 2, 4, 6 — not 0+1, 2+3), and a
SEQ4() in a subquery agrees with one in the block above it. A counter incremented inside
the function — the shape RANDOM and UUID_STRING use — would number the CALLS and
get every one of those wrong, which is why the count lives out here and the function only reads it.
Set once per row by the operator that iterates rows, so all of a row's expressions see one
value. That also places the count where Snowflake places it: an operator numbers the rows it is
HANDED, so a WHERE that ran earlier in the pipeline has already removed rows and the projection
numbers the survivors from 0 — live, SELECT x, SEQ4() FROM t WHERE x > 4 over 1..8 returns
5|0 6|1 7|2 8|3.
Scoped to the thread, like ExpressionSource and the statement clock, because a session's
statements run on the caller's thread. Unset means row 0: a SELECT with no FROM never
reaches an operator at all, and live answers SEQ4() there with 0.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Longbegin(long ordinal) Note the row about to be evaluated, returning whatever ordinal it displaced so a nested evaluation — a scalar subquery runs its own operators mid-row — can put it back.static longcurrent()The current row's 0-based ordinal, or 0 when nothing has set one.static voidPut back whateverbegin(long)displaced; null clears.
-
Method Details
-
begin
Note the row about to be evaluated, returning whatever ordinal it displaced so a nested evaluation — a scalar subquery runs its own operators mid-row — can put it back. -
end
Put back whateverbegin(long)displaced; null clears. -
current
public static long current()The current row's 0-based ordinal, or 0 when nothing has set one.
-