Configure a TDSQL for MySQL source component
The TDSQL for MySQL source component reads data from a TDSQL for MySQL data source. To synchronize this data to another data source, configure the source component, and then the destination component. This topic describes how to configure a TDSQL for MySQL source component.
Prerequisites
-
A TDSQL for MySQL data source has been created. For more information, see Create a TDSQL for MySQL data source.
-
The account for configuring the component must have synchronization read permission on the data source. If you do not have the required permission, you must request it. For more information, see Apply for data source permissions.
Procedure
-
In the top navigation bar of the Dataphin homepage, choose Develop > Data Integration.
-
In the top navigation bar of the Data Integration page, select a project. If you are using Dev-Prod mode, you must also select an environment.
-
In the left-side navigation pane, click Batch Integration. In the Batch Integration list, click the batch pipeline to develop to open its configuration page.
-
In the upper-right corner of the page, click Component Library to open the Component Library panel.
-
In the left-side navigation pane of the Component Library panel, select Source. Find the TDSQL for MySQL component in the list on the right and drag it onto the canvas.
-
On the TDSQL for MySQL source component card, click the
icon to open the TDSQL for MySQL Source Configuration dialog box. -
In the TDSQL for MySQL Source Configuration dialog box, configure the parameters.
Parameter
Description
Step name
The name of the TDSQL for MySQL source component. Dataphin automatically generates a step name, which you can change as needed. The name must meet the following requirements:
-
Can contain only Chinese characters, letters, underscores (_), and digits.
-
Cannot exceed 64 characters in length.
Number of source tables
Select the number of source tables. The options are Single table and Multiple tables.
-
Single table: Synchronizes data from one source table to one destination table.
-
Multiple tables: Synchronizes data from multiple source tables to a single destination table by using the UNION algorithm.
For more information about the UNION operator, see INTERSECT, UNION, and EXCEPT.
Data source
From the data source drop-down list, select a data source. The list displays all TDSQL for MySQL data sources in the current Dataphin project, regardless of whether you have synchronization read permission. If Number of source tables is set to Single table, you can select only one data source. Click the
icon to copy the name of the current data source. If Number of source tables is set to Multiple tables, you can select multiple data sources that are in the same time zone.-
If you lack synchronization read permission for a data source, click Apply next to it to request permission. For more information, see Apply for data source permissions.
-
If you do not have a TDSQL for MySQL data source, click Create Data Source from the drop-down list. For more information, see Create a TDSQL for MySQL data source.
Database (Optional)
Select the database that contains the source table. If you leave this parameter empty, Dataphin uses the database specified during data source registration.
If you select Multiple tables, you can select multiple databases. Click the
icon to view all selected databases in the Database List dialog box.Table matching method
Select General rule or Database regular expression.
NoteThis parameter is available only when Number of source tables is set to Multiple tables.
Table
Select the source table or tables.
-
If Number of source tables is set to Single table, you can search for a table by entering a keyword, or enter the exact table name and click Exact Match. After you select a table, the system automatically checks its status. Click the
icon to copy the name of the selected table. -
If Number of source tables is set to Multiple tables, enter an expression to add tables based on the selected matching method.
-
If you select General Rule as the table matching method, you can enter a table expression in the input box to filter for tables with the same structure. The system supports expressions in enumeration format, regex-like format, or a hybrid of both. For example,
table_[001-100];table_102;table_abc*. The*wildcard is valid only at the beginning or end of an expression. -
If Table matching method is set to Database regular expression: In the input field, enter a regular expression that the current database supports. The system uses this expression to match tables in the target database. At runtime, the task uses this expression to dynamically match a set of tables for synchronization.
After entering the expression, you can click Exact Match to view a list of matched tables in the Confirm Match Details dialog box.
-
Split key (Optional)
The system splits data into shards based on the configured split key. This enables parallel reads when combined with the concurrency setting. You can use a column from the source data table as the split key. For optimal performance, use a column with a primary key or an index as the split key.
ImportantIf you select a date or time column, the system identifies the maximum and minimum values and performs a brute-force split based on the total time range and concurrency. An even data distribution is not guaranteed.
Input filter (Optional)
Specifies a filter condition to extract specific data. The following formats are supported:
-
Fixed value: Extracts data that matches the specified value. For example,
ds=20211111. -
Variable: Extracts a subset of data by using a variable. For example,
ds=${bizdate}.
Output fields
The output field section displays all fields from the selected tables that match the filter conditions. You can perform the following operations:
-
Manage fields: You can adjust the output fields in the Manage fields dialog box.
-
Delete individual fields: To remove a field, click the
icon in the Actions column. -
Delete fields in bulk: To remove multiple fields, click Manage fields. In the Manage fields dialog box, select the fields you want to remove, click the
left arrow icon to move them to the unselected list, and then click OK.
-
-
Add in bulk: Click Add in bulk to configure fields by using JSON, TEXT, or DDL format.
NoteAfter you add fields in bulk and click OK, the new configuration overwrites the existing field configuration.
-
To configure fields in JSON format, use the following example:
// Example: [{ "index": 1, "name": "id", "type": "int(10)", "mapType": "Long", "comment": "comment1" }, { "index": 2, "name": "user_name", "type": "varchar(255)", "mapType": "String", "comment": "comment2" }]Noteindexspecifies the column index,namespecifies the name of the output field, andtypespecifies the data type of the output field. For example,"index":3,"name":"user_id","type":"String"imports the third column, names the output fielduser_id, and sets its data type toString. -
To configure fields in TEXT format, use the following example:
// Example: 1,id,int(10),Long,comment1 2,user_name,varchar(255),Long,comment2-
The row delimiter separates each field definition. The default is the newline character (
\n). Semicolons (;) and periods (.) are also supported. -
The column delimiter separates the properties within each field definition, such as index, name, and type. The default is the comma (,).
The field type can be omitted.
-
-
To configure fields in DDL format, use the following example:
CREATE TABLE tablename ( user_id serial, username VARCHAR(50), password VARCHAR(50), email VARCHAR (255), created_on TIMESTAMP, );
-
-
Create output field: Click + Create output field, and then specify the Field, Type, and Comment, and select a mapping type. After you configure the current row, click the
icon to save it.System field: You can select a system variable to identify the source of each row of data. This is useful when you synchronize data from multiple tables (such as sharded databases and tables) to a single destination table. After you select a system variable, the system automatically populates the field type and mapping type. The available system variables include:
-
dp_datasource: The name of the source data source. -
dp_dbname: The name of the source database, if any. -
dp_schema: The name of the source schema, if any. -
dp_source_table: The name of the source table. -
dp_read_timestamp: The time when the SELECT operation started on the source.
You can concatenate the values of multiple system variables. For example,
dp_dbname.dp_source_table.Note-
You cannot modify the field type and mapping type of a system variable.
-
The
dp_read_timestampvariable must be used alone and cannot be concatenated with other variables.
-
-
-
Click OK to save the TDSQL for MySQL source component configuration.

icon to save it.