THRESHOLD()

Scalar. Determines whether or not the value in a given column crosses a specified threshold.

Syntax

THRESHOLD(UP | DOWN | ANY, column, value)
Parameters

column

The name of a stream or window column containing a numeric or time value.

value

The threshold value. Must be the same data type as the column specified with column.

Data Types

Return

column

value

Boolean

String

Integer

Long

Float

Interval

Timestamp

Usage

This function returns True if the value in the specified column of the current row is greater than value after having been less than or equal to value in the previous row (for UP), or less than value after previously being greater than or equal to value (for DOWN), or either (for ANY). Note that this function returns True for the first row in a stream or window if the value of the specified column is greater than value (for UP), less than value (for DOWN), or not equal to value (for ANY).

If using this function for a window partitioned with GROUP BY or PER, the threshold comparison applies to each partition individually, not the window as a whole.

Example

The following example query publishes a row to its destination stream when the value of the Trades.Price column exceeds 100:

INSERT INTO OutStream
SELECT Symbol, Price, Volume
FROM Trades
WHERE THRESHOLD(UP, Trades.Price, 100);