coalesce

Description

Return the first non-null argument or null if all are null. All arguments must have the same data type.

Return type

expression

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

coalesce(expression_1, expression_2, ...)

Argument

Type

Optional

Repeatable

Restrictions

expression

storable

no

yes

none

Examples

make_col foo:coalesce(bar, baz, 0)

Create a new column ‘foo’, where for each row, the value of column ‘foo’ is set to the value of column ‘bar’ if it isn’t null, or to the value of column ‘baz’ if it isn’t null, or 0.