Add or update map(添加或更新映射)¶
Supported in: Batch, Streaming
Updates a value by key in a map or adds new key value pair.
Expression categories: Map
Declared arguments¶
- Expression: Expression to set as value for the key.
Expression\ - Key: Key to add or update.
Expression\ - Map: Map expression.
Expression\
Type variable bounds: K accepts AnyType**V accepts AnyType
Output type: Map\
Examples¶
Example 1: Base case¶
Argument values:
- Expression: 4
- Key: k
- Map:
map_col
| map_col | Output |
|---|---|
| { a -> 1, b -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
Example 2: Base case¶
Argument values:
- Expression: 4
- Key: k
- Map:
map_col
| map_col | Output |
|---|---|
| { a -> 1, b -> 2, k -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
| { a -> 1, b -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
Example 3: Base case¶
Argument values:
- Expression: 4
- Key: k
- Map:
map_col
| map_col | Output |
|---|---|
| { a -> 1, b -> 2, k -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
Example 4: Null case¶
Argument values:
- Expression: 4
- Key: null
- Map:
map_col
| map_col | Output |
|---|---|
| { a -> 1, } |
{ a -> 1, } |
Example 5: Null case¶
Argument values:
- Expression: 4
- Key: k
- Map:
map_col
| map_col | Output |
|---|---|
| null | null |
中文翻译¶
添加或更新映射¶
支持:批处理(Batch)、流处理(Streaming)
根据映射中的键更新值,或添加新的键值对。
表达式类别: 映射(Map)
声明的参数¶
- 表达式(Expression): 要设置为键值的表达式。
Expression\ - 键(Key): 要添加或更新的键。
Expression\ - 映射(Map): 映射表达式。
Expression\
类型变量边界: K 接受任意类型(AnyType)**V 接受任意类型(AnyType)
输出类型: Map\
示例¶
示例 1:基础情况¶
参数值:
- 表达式(Expression): 4
- 键(Key): k
- 映射(Map):
map_col
| map_col | 输出(Output) |
|---|---|
| { a -> 1, b -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
示例 2:基础情况¶
参数值:
- 表达式(Expression): 4
- 键(Key): k
- 映射(Map):
map_col
| map_col | 输出(Output) |
|---|---|
| { a -> 1, b -> 2, k -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
| { a -> 1, b -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
示例 3:基础情况¶
参数值:
- 表达式(Expression): 4
- 键(Key): k
- 映射(Map):
map_col
| map_col | 输出(Output) |
|---|---|
| { a -> 1, b -> 2, k -> 2, } |
{ a -> 1, b -> 2, k -> 4, } |
示例 4:空值情况¶
参数值:
- 表达式(Expression): 4
- 键(Key): null
- 映射(Map):
map_col
| map_col | 输出(Output) |
|---|---|
| { a -> 1, } |
{ a -> 1, } |
示例 5:空值情况¶
参数值:
- 表达式(Expression): 4
- 键(Key): k
- 映射(Map):
map_col
| map_col | 输出(Output) |
|---|---|
| null | null |