Window Functions

first_value(value any)

Returns the first value of input rows.

Parameters:value – input value
Return type:same as parameter data type
last_value(value any)

Returns the last value of input rows.

Parameters:value – input value
Return type:same as parameter data type
lag(value any[, offset integer[, default any]])

Returns value evaluated at the row that is offset rows before the current row within the partition. If there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null.

Parameters:
  • value – input value
  • offset – offset
  • default – default value
Return type:

same as parameter data type

lead(value any[, offset integer[, default any]])

Returns value evaluated at the row that is offset rows after the current row within the partition. If there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null.

Parameters:
  • value – input value
  • offset – offset
  • default – default value
Return type:

same as parameter data type

rank()

Returns rank of the current row with gaps.

Return type:int8
row_number()

Returns the current row within its partition, counting from 1.

Return type:int8