Modified the write method Append/Update/Delete Data Based on Identifier Field to Add/Modify/Delete Data Based on Identifier Field.
This document introduces the configuration items on the Write Method tab page of the Data Synchronization node and the DB Table Output operator in the Data Transformation node.
The following figure shows the Write Method tab page.
The three write methods are described in the following table.
Some data sources provide limited support for Write Method. For details, see Functional Limitations of Different Data Sources.
In V4.1.3 and later versions, partition writing is supported when the target table is in Apache Hive or Transwarp Inceptor. For details, see Partition Table Creation and Data Reading/Writing.
If the target table has no physical primary key and no logical primary key mapping has been configured, data will be written into the target table directly.
Effect Description of Different Write Methods
If the target table has a physical primary key or has been configured with logical primary key mapping, the system compares data rows in the source and target tables based on the primary key value.
1. For data rows with different primary key values, data will be appended to the target table.
2. For data rows with the same primary key value, three writing strategies are available:
Overwrite Data in Target Table If Same Primary Key Value Exists
Ignore Source Data If Same Primary Key Value Exists
Record as Dirty Data If Same Primary Key Value Exists
Write Data into Target Table after Emptying it
Data is written into the target table after the target table is emptied. This write method is available with or without a primary key.
Add/Modify/Delete Data Based on Identifier Field
1. If the target table has no physical primary key, you must set the logical primary key in Primary Key Mapping when Modify or Delete is selected in Write Method.
2. If the target table has a physical primary key or has been configured with logical primary key mapping, the identifier value of each data row will be recognized.
Ignore identical data that exists in both the source and target tables.
Add data that only exists in the source table to the target table.
Update the target table data with the modified source table data.
Delete data that only exists in the target table.
Establish the correspondence between the rows of the source table and the target table, as shown in the following figure.
1. If the target table has a physical primary key or you have set the primary key for the target table to be created, the primary key mapping relationship will be automatically generated according to the physical primary key of the target table to ensure data uniqueness.
2. If the target table has no physical primary key:
If Target Table is set to Auto Created Table, you can manually set one or more fields as the physical primary key in Field Mapping.
If Target Table is set to Existing Table, you can select the field as the logical primary key in Primary Key Mapping for mapping to ensure data uniqueness. If no field is selected, data will be written into the target table directly.
You need to configure Strategy for Primary Key Conflict if any of the following conditions are met:
The target table has a physical primary key.
The target table has no physical primary key but has been configured with logical primary key mapping.
Three strategies for the primary key conflict are available:
This write method is not supported when the target data source is Hive.
You can select one or more options among Add, Modify, and Delete.
Identifier Field and Identifier Value
1. You can filter the data you need to add/modify/delete based on the identifier field and its value.
2. If you have used the Data Comparison operator, Identifier Field defaults to fdl_comparison_type, and Identifier Value defaults to the fdl_comparison_type value.
3. If only one option among Add, Modify, and Delete is selected, you can leave Identifier Field empty, and the selected write method will take effect on all the read data.
Primary Key Mapping
For details, see the section "Primary Key Mapping" of this document.
1. Primary Key Mapping is displayed when Modify or Delete is selected in Write Method.
2. When Modify or Delete is selected in Write Method, Primary Key Mapping must be configured.
1. The Data Comparison operator is usually used in combination with the DB Table Output operator. For details, see Data Comparison Example.
2. The application scenario of a single Data Synchronization node includes:
You want to add/modify/delete data based on the filtering result.
You want to add/modify/delete data based on the identifier field and its value.
For details, see Adding/Modifying/Deleting Data Based on the Identifier Field.
Assume that null values exist in the D column of both the source table and the target table.
You have set Write Method to Write Data into Target Table Directly, selected fields A, B, C, and D as logical primary keys, and set Strategy for Primary Key Conflict to Overwrite Data in Target Table If Same Primary Key Value Exists, as shown in the following figure.
After execution, for primary key conflicts with not-null values, the source data overwrites the target data. (See the first record in the following figure.) For primary key conflicts with null values, the source data is appended to the target table without overwriting the existing data.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy