The MySQL input component reads data from a MySQL data source. To synchronize data from a MySQL data source to a target, first configure the MySQL input component for the source, and then configure the target component. This topic describes how to configure the MySQL input component.
Prerequisites
A MySQL data source has been created. For more information, see Create a MySQL data source.
The account used to configure the MySQL input component must have the sync read permission on the data source. If you do not have this permission, you must apply for it. For more information, see Apply for data source permissions.
Procedure
In the top navigation bar of the Dataphin homepage, choose Develop > Data Integration.
Select a Project in the top navigation bar. If you are using the Dev-Prod mode, you also need to select an environment.
In the left-side navigation pane, click Offline Integration. In the Offline Integration list, click the desired Offline Pipeline 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 Input. In the input component list on the right, find the MySQL component, and then drag it to the canvas.
On the MySQL component card, click the
icon to open the MySQL Input Configuration dialog box.In the MySQL Input Configuration dialog box, configure the parameters.
Parameter
Description
Step name
The name of the MySQL input component. Dataphin automatically generates a step name, but you can change it as needed. The name must follow these rules:
Can contain only Chinese characters, letters, underscores (_), and digits.
Cannot exceed 64 characters in length.
Source table mode
Specifies whether to read from a single table or multiple tables. The options are Single Table and Multiple Tables.
Single Table: Use this mode to synchronize data from one source table to one target table.
Multiple Tables: Use this mode to synchronize data from multiple source tables to a single target table. Data from multiple tables is merged into the target table using the UNION algorithm.
Data source
The drop-down list shows all MySQL data sources in Dataphin, including those for which you have the sync read permission and those for which you do not. If you set Source Table Mode to Single Table, you can select only one data source. Click the
icon to copy the current data source name. If you set Source Table Mode to Multiple Tables, you can select multiple data sources that use the same time zone.If you lack the sync read permission for a data source, click Apply next to it to request the permission. For more information, see Apply for data source permissions.
If you do not have a MySQL data source, click New Data Source in the drop-down list to create one. For more information, see Create a MySQL data source.
Time zone
The time zone for processing time-based data. By default, this is the time zone configured for the selected data source and cannot be changed.
NoteFor tasks created before version 5.1.2, you can select Default Data Source Configuration or Channel Time Zone. The default option is Channel Time Zone.
Default Data Source Configuration: The default time zone of the selected data source.
Channel Time Zone: The time zone configured for the current integration task under Properties > Channel Configuration.
Database (Optional)
The database containing the source table. If you leave this empty, the database specified in the data source configuration is used.
If you set Source Table Mode to Multiple Tables, you can select multiple databases. Click the
icon to view all selected databases in the Database List dialog box.Table matching mode
You can select General Rule or Database Regular Expression.
NoteThis parameter appears only when you set Source Table Mode to Multiple Tables.
Table
Select the source table or tables.
If you set Source Table Mode to Single Table, you can enter a keyword to search for a table, or enter the full table name and click Exact Match. After you select a table, the system automatically checks its status. Click the
icon to copy the selected table name.If you set Source Table Mode to Multiple Tables, you can add tables by entering an expression based on the selected table matching mode.
If you select General Rule: In the input box, enter a table expression to select tables that share the same schema. The system supports enumerated lists, regular expression-like patterns, and a mix of both. For example:
table_[001-100];table_102;table_abc*. The asterisk (*) wildcard is supported only at the beginning or end of a pattern.If you select Database Regular Expression: Enter a regular expression that is supported by the source database. The system uses this expression to match tables in the source database. When the task runs, it synchronizes data from all tables that currently match the expression.
After you enter the expression, click Exact Match to view a list of matched tables in the Confirm Match Details dialog box.
Split key (Optional)
The column used to partition the source data for parallel reading. The system shards the data based on this key. This allows for parallel data reads based on the concurrency setting. For optimal performance, we recommend using a primary key or an indexed column as the split key.
ImportantIf you select a date or time column, the system splits the data based on the time range and concurrency level. The data distribution is not guaranteed to be even.
Input filter (Optional)
A filter condition to apply during data extraction. The following formats are supported:
Fixed value: Extracts specific data. For example,
ds=20211111.Variable parameter: Extracts a subset of data. For example,
ds=${bizdate}.
Output field
Displays the fields from the selected source table(s). You can perform the following operations:
Field Management: You can adjust the output fields in the Field Management dialog box.
Delete a single field: To remove a single field, click the
icon in its Actions column.Delete fields in bulk: To remove multiple fields in bulk, click Field Management. In the Field Management dialog box, select the fields you want to remove, click the
left arrow icon to move them from the selected list, and then click OK.
Batch Add: Click Batch Add to configure fields in bulk by using JSON, TEXT, or DDL format.
NoteAfter you click OK, the new fields will overwrite the existing field configuration.
To configure fields in JSON format:
// 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 number,namespecifies the field name after import, andtypespecifies the field data type. For example,"index":3,"name":"user_id","type":"String"imports the third column from the file, names the fielduser_id, and sets its data type to String.To configure fields in TEXT format:
// Example: 1,id,int(10),Long,comment1 2,user_name,varchar(255),Long,comment2The Row Delimiter separates the information for each field. The default is a newline character (\n). Other supported delimiters include the semicolon (;) and the period (.).
The column separator is used to separate field names from field types, and the default is a half-width comma (,). Supported separators include
','. The field type can be omitted, and defaults to','.
To configure fields in DDL format:
CREATE TABLE tablename ( user_id serial, username VARCHAR(50), password VARCHAR(50), email VARCHAR (255), created_on TIMESTAMP, );
New Output Field: Click + New Output Field, enter the Field, Type, and Comment, and select a mapping type as prompted. After you configure the row, click the
icon to save your changes.System field: You can select a system field to identify the origin of each row of data. After you select a system field, the system automatically fills in the field type and mapping type. This is useful when you synchronize data from multiple tables (for example, from sharded databases and tables) to a single target table. The available system fields include:
dp_datasource: The name of the synchronized data source.dp_dbname: The name of the synchronized database, if any.dp_schema: The name of the synchronized schema, if any.dp_source_table: The name of the synchronized source table.dp_read_timestamp: The time when the source SELECT statement started.
You can concatenate multiple system variables, for example,
dp_dbname.dp_source_table.NoteThe field type and mapping type of a system field cannot be modified.
dp_read_timestampcan only be configured separately and does not support concatenation.
Click Confirm to save the configuration of the MySQL input component.