跳转至

Max by(Max by(最大值依据))

Supported in: Streaming

This expression computes a max row according to the max column expression after applying the provided filter specification. If there is no maximum row, null will be returned.

Expression categories: Aggregate

Declared arguments

  • Expression: Column expression on which the max is computed. Null values are treated as if they have the smallest value.
    Expression\
  • Output projection expression: Defines the projection expression that is applied on the maximum row before it is returned.
    Expression\
  • optional Filter condition: This parameter defines the filter specification that is applied on the rows contained within the window. The output of this expression will only reference rows which are not filtered by this parameter (i.e., where the condition evaluates to true). If no rows exist in state at the time of a trigger, null will be emitted.
    Expression\

Output type: AnyType

Examples

Example 1: Base case

Argument values:

  • Expression: salary
  • Output projection expression: salary
  • Filter condition:
    lessThan(
     left: salary,
     right: 5000,
    )

Given input table:

dep_name salary
develop 9900
develop 4000
develop 3000

Outputs: 4000


Example 2: Base case

Argument values:

  • Expression: salary
  • Output projection expression: salary
  • Filter condition: null

Given input table:

dep_name salary
develop 1000
develop null
develop 4000

Outputs: 4000



中文翻译


Max by(最大值依据)

支持:流式处理(Streaming)

该表达式在应用指定的过滤条件后,根据最大值列表达式计算最大值行。如果不存在最大值行,则返回 null。

表达式类别: 聚合(Aggregate)

声明的参数

  • 表达式(Expression): 用于计算最大值的列表达式。Null 值被视为具有最小值。
    Expression\
  • 输出投影表达式(Output projection expression): 定义在返回最大值行之前应用于该行的投影表达式。
    Expression\
  • 可选 过滤条件(Filter condition): 该参数定义应用于窗口内行的过滤规范。此表达式的输出仅引用未被此参数过滤的行(即条件评估为 true 的行)。如果在触发时状态中不存在任何行,则将输出 null。
    Expression\

输出类型: AnyType

示例

示例 1:基本情况

参数值:

  • 表达式: salary
  • 输出投影表达式: salary
  • 过滤条件:
    lessThan(
     left: salary,
     right: 5000,
    )

给定输入表:

dep_name salary
develop 9900
develop 4000
develop 3000

输出: 4000


示例 2:基本情况

参数值:

  • 表达式: salary
  • 输出投影表达式: salary
  • 过滤条件: null

给定输入表:

dep_name salary
develop 1000
develop null
develop 4000

输出: 4000