Array position(数组位置(Array position))¶
Supported in: Batch, Faster, Streaming
Returns a position/index of the first occurrence of the 'value' in a given array. Returns null when value is not found or when any of the arguments are null.
Expression categories: Array
Declared arguments¶
- Array: Array from which to return element's position.
Expression\> - Value: Value for which to find position in the array.
Expression\
Type variable bounds: T accepts AnyType
Output type: Long
Examples¶
Example 1: Base case¶
Argument values:
- Array: [ 10, 11, 12 ]
- Value: 10
Output: 1
Example 2: Null case¶
Description: Output null if element is not found.
Argument values:
- Array: [ 1, 2, 4 ]
- Value: 10
Output: null
Example 3: Null case¶
Argument values:
- Array:
array - Value:
value
| array | value | Output |
|---|---|---|
| [ 1, 2, 3 ] | null | null |
| [ ] | null | null |
| null | 1 | null |
| null | null | null |
中文翻译¶
数组位置(Array position)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
返回给定数组中首次出现"值(value)"的位置/索引。当未找到该值或任一参数为null时,返回null。
表达式类别: 数组(Array)
声明参数¶
- 数组(Array): 从中返回元素位置的数组。
表达式\> - 值(Value): 要在数组中查找其位置的值。
表达式\
类型变量约束: T 接受任意类型(AnyType)
输出类型: 长整型(Long)
示例¶
示例1:基本情况¶
参数值:
- 数组: [ 10, 11, 12 ]
- 值: 10
输出: 1
示例2:空值情况¶
描述: 如果未找到元素,则输出空值(null)。
参数值:
- 数组: [ 1, 2, 4 ]
- 值: 10
输出: null
示例3:空值情况¶
参数值:
- 数组:
array - 值:
value
| array | value | 输出(Output) |
|---|---|---|
| [ 1, 2, 3 ] | null | null |
| [ ] | null | null |
| null | 1 | null |
| null | null | null |