跳转至

First non null value (coalesce)(首个非空值(coalesce))

Supported in: Batch, Faster, Streaming

Picks first non null value of the inputs. Known as coalesce in sql.

Expression categories: Data preparation

Declared arguments

  • Expressions: The first non null values of these expressions will be returned.
    List\>
  • optional Treat empty strings as null: Treat all empty strings as null values.
    Literal\

Type variable bounds: T accepts AnyType

Output type: T

Examples

Example 1: Base case

Argument values:

  • Expressions: [tail_number, airline]
  • Treat empty strings as null: null
tail_number airline Output
XB-123 null XB-123
null MT MT

Example 2: Base case

Argument values:

  • Expressions: [tail_number, airline]
  • Treat empty strings as null: true
tail_number airline Output
XB-123 null XB-123
empty string MT MT

Example 3: Null case

Argument values:

  • Expressions: [tail_number, airline]
  • Treat empty strings as null: null
tail_number airline Output
null null null


中文翻译


首个非空值(coalesce)

支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)

选取输入值中的首个非空值。在 SQL 中称为 coalesce。

表达式类别: 数据准备

声明的参数

  • 表达式(Expressions): 将返回这些表达式中的首个非空值。
    List\>
  • 可选 将空字符串视为空值(Treat empty strings as null): 将所有空字符串视为空值。
    Literal\

类型变量范围: T 接受任意类型(AnyType)

输出类型: T

示例

示例 1:基础情况

参数值:

  • 表达式(Expressions): [tail_number, airline]
  • 将空字符串视为空值(Treat empty strings as null): null
tail_number airline 输出(Output)
XB-123 null XB-123
null MT MT

示例 2:基础情况

参数值:

  • 表达式(Expressions): [tail_number, airline]
  • 将空字符串视为空值(Treat empty strings as null): true
tail_number airline 输出(Output)
XB-123 null XB-123
空字符串 MT MT

示例 3:空值情况

参数值:

  • 表达式(Expressions): [tail_number, airline]
  • 将空字符串视为空值(Treat empty strings as null): null
tail_number airline 输出(Output)
null null null