first_not_null#

Description#

Return the first non-null value of one column across an ordered group.

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, the first value is the earliest.

Return type#

storable value

Domain#

This is an aggregate function (aggregates rows over a group in aggregate verbs.)

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

Categories#

Usage#

first_not_null(expression, [ order_by ])

Argument

Type

Optional

Repeatable

Restrictions

expression

storable value

no

no

none

order_by

ordering

yes

no

constant

Examples#

make_col first_value:window(first_not_null(value), group_by(kind))

Find out the first non-null within each kind.

statsby first_customer:first_not_null(customer_id), group_by(category)

Find out the first non-null customer within each category.

statsby first_customer:first_not_null(customer_id, order_by(login_time)), group_by(category)

Find out the non-null customer that logged in first within each category.