All Products
Search
Document Center

DataWorks:Edit field and assign value

Last Updated:Mar 26, 2026

During real-time single-table synchronization, the records written to your destination often need to carry additional context that does not exist in the source — such as the source table name, a processing timestamp, or a version tag. The Edit Field and Assign Value component lets you add new fields inline during synchronization and write them to the destination, without modifying the source schema. You can populate new fields using constants, built-in metadata variables, or built-in functions.

Prerequisites

Before you begin, ensure that you have:

Note

The Edit Field and Assign Value component is only available between the Source and Destination components in a single-table real-time synchronization task. For supported data sources, see Supported data sources and synchronization solutions.

Add and configure the component

  1. In the real-time single-table synchronization task configuration, turn on the Data Processing switch.

  2. Click +Add Node and select Edit Field and Assign Value.

  3. Configure the component.

    image

Upstream fields

The Upstream fields section lists all fields from the upstream output. Each field has four columns:

ColumnDescription
Field nameThe name of the field from the upstream output.
TypeThe data type of the field from the upstream output.
ValueFor existing upstream fields, values are inherited from the upstream output. For new fields, specify how the value is generated.
ActionsDetermines whether to pass the field to the downstream component.

Add a custom field

Click Add field in the lower-left corner of the Edit Field and Assign Value page to add a new field. For each new field, choose one of three value generation methods:

Assignment

Assigns a constant you enter to the new field. The constant is converted to the specified data type.

When to use: Use Assignment when the new field always holds the same value — for example, a data version tag (v2), an environment label (prod), or a fixed region code.

Variable

Assigns the value of a built-in variable to the new field at runtime.

When to use: Use Variable when you need to capture metadata about the synchronization task itself — for example, tracking which source table a record came from, or when the record was processed.

Note

Variable support depends on the characteristics of the source and destination.

The following built-in variables are supported:

CategoryVariable nameDescription
SourcePROCESS_TIMEThe time when the synchronization task processes the record. This is a 13-digit millisecond timestamp.
SourceDATASOURCE_NAME_SRCThe name of the source data source.
SourceDB_NAME_SRCThe name of the source database.
SourceSCHEMA_NAME_SRCThe name of the source schema.
SourceTABLE_NAME_SRCThe name of the source table.
SourceTOPIC_NAME_SRCThe name of the source topic.
DestinationTABLE_NAME_DESTThe name of the destination table.
DestinationTOPIC_NAME_DESTThe name of the destination topic.
DestinationSCHEMA_NAME_DESTThe name of the destination schema.
DestinationDB_NAME_DESTThe name of the destination database.
DestinationDATASOURCE_NAME_DESTThe name of the destination data source.

Function

Performs a calculation during synchronization and assigns the result to the new field.

When to use: Use Function when you need to transform a field value — for example, converting a UNIX timestamp to a human-readable date string, or extracting a substring from a text field.

Note

If a function throws an exception while processing a record, that record is counted as dirty data in the synchronization task's dirty data statistics. Depending on your dirty data tolerance configuration, the task may terminate.

The following functions are supported:

DATE_FORMAT

Converts a timestamp to a formatted date string.

ParameterDescription
Parameter 1An upstream field of a numeric type: a 10-digit UNIX timestamp or a 13-digit millisecond timestamp.
Parameter 2The timestamp type: unix for a 10-digit UNIX timestamp, or millis for a 13-digit millisecond timestamp.
Parameter 3The time zone for the conversion, for example, Asia/Shanghai.
Parameter 4The target date string format, for example, yyyy-MM-dd HH:mm:ss. Format tokens: yyyy (year), MM (month), dd (day), HH (hour, 24-hour format), mm (minute), ss (second), SSS (millisecond), ZZ (time zone).

Example: DATE_FORMAT(ts_field, "millis", "Asia/Shanghai", "yyyy-MM-dd HH:mm:ss") converts the millisecond timestamp 1711411200000 to 2024-03-26 08:00:00.

TO_TIMESTAMP

Converts a formatted date string to a timestamp.

ParameterDescription
Parameter 1An upstream field of a text type representing a time string.
Parameter 2The target timestamp type: unix for a 10-digit UNIX timestamp, or millis for a 13-digit millisecond timestamp.
Parameter 3The time zone for the conversion, for example, Asia/Shanghai.
Parameter 4The time string format, for example, yyyy-MM-dd HH:mm:ss. Format tokens follow the same convention as DATE_FORMAT.

Example: TO_TIMESTAMP(date_str, "millis", "Asia/Shanghai", "yyyy-MM-dd HH:mm:ss") converts the string 2024-03-26 08:00:00 to 1711411200000.

SUBSTRING

Extracts a substring from a text field.

ParameterDescription
Parameter 1An upstream field of a text type.
Parameter 2The starting position of the substring (inclusive). The minimum value is 0.
Parameter 3The length of the substring. If the value is 0 or negative, the substring extends from the starting position to the end of the string.

Example: SUBSTRING(code_field, 0, 3) extracts the first three characters from a field value such as CN-PROD-001, returning CN-.

What's next

After configuring the component:

  1. Click Data Output Preview to verify that the output data meets your requirements.

  2. Map new fields to destination table fields in the field mapping. New fields are written to the destination only after this mapping is configured.