Add or update struct field(添加或更新结构体字段(Add or update struct field))¶
Supported in: Batch, Faster, Streaming
Updates a field of a struct or adds a new field.
Expression categories: Struct
Declared arguments¶
- Expression: Expression to update struct field with.
Expression\ - Locator: Locate inner elements with multiple entries like ['author', 'email'].
StructLocator - Struct: The struct to update.
Expression\
Output type: Struct
Examples¶
Example 1: Base case¶
Argument values:
- Expression:
value - Locator: flight
- Struct:
struct
| struct | value | Output |
|---|---|---|
| { airline: { id: NA, }, } |
foo | { airline: { id: NA, }, flight: foo, } |
Example 2: Base case¶
Argument values:
- Expression:
value - Locator: flight
- Struct:
struct
| struct | value | Output |
|---|---|---|
| { airline: { id: FE, }, } |
{ id: 1, } |
{ airline: { id: FE, }, flight: { id: 1, }, } |
Example 3: Base case¶
Argument values:
- Expression:
value - Locator: airline.id
- Struct:
struct
| struct | value | Output |
|---|---|---|
| { airline: { id: NA, }, } |
1 | { airline: { id: 1, }, } |
| { airline: { id: FE, }, } |
2 | { airline: { id: 2, }, } |
Example 4: Null case¶
Argument values:
- Expression:
value - Locator: airline.id
- Struct:
struct
| struct | value | Output |
|---|---|---|
| null | null | null |
| null | 1 | null |
| { airline: { id: FE, }, } |
null | { airline: { id: null, }, } |
中文翻译¶
添加或更新结构体字段(Add or update struct field)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
更新结构体(struct)的某个字段,或添加一个新字段。
表达式类别: 结构体(Struct)
声明的参数¶
- 表达式(Expression): 用于更新结构体字段的表达式。
表达式\<任意类型> - 定位器(Locator): 通过多个条目定位内部元素,例如 ['author', 'email']。
结构体定位器(StructLocator) - 结构体(Struct): 要更新的结构体。
表达式\<结构体>
输出类型: 结构体(Struct)
示例¶
示例 1:基础情况¶
参数值:
- 表达式:
value - 定位器: flight
- 结构体:
struct
| struct | value | 输出 |
|---|---|---|
| { airline: { id: NA, }, } |
foo | { airline: { id: NA, }, flight: foo, } |
示例 2:基础情况¶
参数值:
- 表达式:
value - 定位器: flight
- 结构体:
struct
| struct | value | 输出 |
|---|---|---|
| { airline: { id: FE, }, } |
{ id: 1, } |
{ airline: { id: FE, }, flight: { id: 1, }, } |
示例 3:基础情况¶
参数值:
- 表达式:
value - 定位器: airline.id
- 结构体:
struct
| struct | value | 输出 |
|---|---|---|
| { airline: { id: NA, }, } |
1 | { airline: { id: 1, }, } |
| { airline: { id: FE, }, } |
2 | { airline: { id: 2, }, } |
示例 4:空值情况¶
参数值:
- 表达式:
value - 定位器: airline.id
- 结构体:
struct
| struct | value | 输出 |
|---|---|---|
| null | null | null |
| null | 1 | null |
| { airline: { id: FE, }, } |
null | { airline: { id: null, }, } |