field.rename
Rename a group of fields.
Description
Rename a group of field names to new names. It is not
allowed to rename top-level fields (.Operation
, .Position
,
.Key
, .Metadata
, .Payload.Before
, .Payload.After
).
Note that this processor only runs on structured data, if the record contains raw
JSON data, then use the processor json.decode
to parse it into structured data first.
Configuration parameters
- YAML
- Table
version: 2.2
pipelines:
- id: example
status: running
connectors:
# define source and destination ...
processors:
- id: example
plugin: "field.rename"
settings:
# Mapping is a comma separated list of keys and values for fields and
# their new names (keys and values are separated by colons ":").
# For example: `.Metadata.key:id,.Payload.After.foo:bar`.
# For more information about the format, see [Referencing
# fields](https://conduit.io/docs/using/processors/referencing-fields).
# Type: string
mapping: ""
# Whether to decode the record key using its corresponding schema from
# the schema registry.
# Type: bool
sdk.schema.decode.key.enabled: "true"
# Whether to decode the record payload using its corresponding schema
# from the schema registry.
# Type: bool
sdk.schema.decode.payload.enabled: "true"
# Whether to encode the record key using its corresponding schema from
# the schema registry.
# Type: bool
sdk.schema.encode.key.enabled: "true"
# Whether to encode the record payload using its corresponding schema
# from the schema registry.
# Type: bool
sdk.schema.encode.payload.enabled: "true"
Name | Type | Default | Description |
---|---|---|---|
mapping | string | null | Mapping is a comma separated list of keys and values for fields and their new names (keys and values are separated by colons ":"). For example: For more information about the format, see Referencing fields. |
sdk.schema.decode.key.enabled | bool | true | Whether to decode the record key using its corresponding schema from the schema registry. |
sdk.schema.decode.payload.enabled | bool | true | Whether to decode the record payload using its corresponding schema from the schema registry. |
sdk.schema.encode.key.enabled | bool | true | Whether to encode the record key using its corresponding schema from the schema registry. |
sdk.schema.encode.payload.enabled | bool | true | Whether to encode the record payload using its corresponding schema from the schema registry. |
Examples
Rename multiple fields
This example renames the fields in .Metadata
and
.Payload.After
as specified in the mapping
configuration parameter.
Configuration parameters
- YAML
- Table
version: 2.2
pipelines:
- id: example
status: running
connectors:
# define source and destination ...
processors:
- id: example
plugin: "field.rename"
settings:
mapping: ".Metadata.key1:newKey,.Payload.After.foo:newFoo"
Name | Value |
---|---|
mapping | .Metadata.key1:newKey,.Payload.After.foo:newFoo |
Record difference
Before | After | ||||
1 | { | 1 | { | ||
2 | "position": null, | 2 | "position": null, | ||
3 | "operation": "create", | 3 | "operation": "create", | ||
4 | "metadata": { | 4 | "metadata": { | ||
5 | - | "key1": "val1" | 5 | + | "newKey": "val1" |
6 | }, | 6 | }, | ||
7 | "key": null, | 7 | "key": null, | ||
8 | "payload": { | 8 | "payload": { | ||
9 | "before": { | 9 | "before": { | ||
10 | "bar": "baz" | 10 | "bar": "baz" | ||
11 | }, | 11 | }, | ||
12 | "after": { | 12 | "after": { | ||
13 | - | "foo": "bar" | 13 | + | "newFoo": "bar" |
14 | } | 14 | } | ||
15 | } | 15 | } | ||
16 | } | 16 | } |