lead_not_null

Description

Return the non-null value of one column in a following row across an ordered group. offset is the number of rows forward from the current row to obtain a value, and any null value does not count towards the offset. The function can still return null if no non-null value is found in the window frame. If no ordering is specified, the default ordering is that of the invoking verb, which is generally the valid_from timestamp, ascending. In this case, lead_not_null(col, 1) returns the next non-null value for column col.

Return type

any

Domain

This is a window function (calculates over a group of multiple input rows using windowing.)

Categories

Usage

lead_not_null( expression, leadby )

Argument

Type

Required

Multiple

expression

any

Required

Only one

leadby

int64

Required

Only one

Examples

make_col next_value:window(lead_not_null(value, 1), group_by(key))

Obtain the next non-null value within the group identified by key and store the results in a new column named next_value.

timestamp

key

value

next_value

100

A

5

3

150

B

6

5

180

A

null

3

200

A

null

3

300

B

5

null

400

A

3

null