Row CCL Operators

Row CCL Operators performs functions on rows.

The square brackets [ ] operator allows you to perform functions on rows other than the current row in a stream or window. This operator uses the following syntax:

stream-or-window-name[index].column

where stream-or-window-name is the name of a data stream or named window and column indicates a column in the stream or window. index is an expression that can include literals, parameters, and/or operators, and that evaluates to an integer. This integer indicates the stream or window row, in relation to the current row or to the window's sort order. (Note that, in this case, the square brackets refer to actual CCL syntax, and do not indicate an optional CCL component.) For example:

MyNamedWindow[1].MyColumn

When used with a data stream, or with a window that is not sorted by largest or smallest value, [0] indicates the current row (as determined by timestamp and order of arrival), [1] indicates the row immediately previous to the current row, and so on.

When [ ] is used with windows that have a LARGEST or SMALLEST clause, index refers to the sorting order specified by the LARGEST or SMALLEST keywords and by their BY column reference subclause. For example, if a window TopTrades is defined to keep the 10 largest values as sorted by its Price column, then TopTrades[0].Price accesses the highest price retained by the window, TopTrades[1].Price refers to the second-highest price, and so on.

When [ ] is used with an unnamed window that is partitioned with the GROUP BY clause, or by any window partitioned by one or more PER clauses, index calculation is based on the partition to which the row belongs, not on the entire window.

The [ ] operator can be used in the WHERE selection condition or the SELECT list.

When used on data streams, the [ ] operator is semantically identical to the PREV() function. When used on windows, the [ ] operator is semantically identical to the LAST() function: