Configure the SelectDB output component

Updated at:

Use the SelectDB output component to write data from external databases or big data storage systems to SelectDB for integration and reprocessing.

Prerequisites

Procedure

  1. In the top navigation bar of the Dataphin homepage, choose Develop > Data Integration.

  2. In the top navigation bar of the integration page, select a Project. If you are in Dev-Prod mode, you also need to select an environment.

  3. In the left-side navigation pane, click offline integration. In the offline integration list, click the offline pipeline you want to configure.

  4. In the upper-right corner of the page, click Component Library to open the Component Library panel.

  5. In the left-side navigation pane of the Component library panel, select Output. In the list of output components on the right, find the SelectDB component and drag it to the canvas.

  6. Drag the image icon from a source, transformation, or process component to the SelectDB output component to connect them.

  7. Click the image icon on the SelectDB output component card to open the SelectDB output configuration dialog box.image

  8. In the SelectDB output configuration dialog box, configure the following parameters.

    Parameter

    Description

    Basic settings

    Step name

    The name of the SelectDB output component. Dataphin automatically generates a step name, which you can modify based on your business scenario. The name must meet the following requirements:

    • Can contain only Chinese characters, letters, underscores (_), and digits.

    • Cannot exceed 64 characters in length.

    Data source

    In the drop-down list, select a SelectDB data source. The list displays all SelectDB data sources, regardless of whether you have sync write permissions. Click the image icon to copy the name of the current data source.

    • If you lack sync write permissions for a data source, click Apply next to the data source to request the permissions. For more information, see Apply for data source permissions.

    • If no SelectDB data source is available, click New data source to create one. For more information, see Create a SelectDB data source.

    Table

    Select the destination table for the output data. You can enter a keyword to search for the table, or enter the exact table name and click Exact search. After you select a table, the system automatically checks its status. Click the image icon to copy the name of the selected table.

    If the destination table does not exist in the SelectDB data source, use the one-click table creation feature to generate it:

    1. Click Create table with one click. Dataphin automatically generates a script to create the destination table. The script includes the destination table name, which defaults to the source table name, and initially converted field types based on its own field definitions.

    2. You can modify the SQL script for table creation based on your business requirements and then click Create. After the destination table is created, Dataphin automatically uses it as the destination table for the output data.

      Note
      • If a table with the same name already exists in the development environment, Dataphin reports an error when you click Create.

      • If no match is found, you can still perform the integration by manually entering a table name.

    Policy for missing production table

    Specifies the policy for handling cases where the production table does not exist. You can select Do Not Process or Auto Create. The default is Auto Create. If you select Do Not Process, the production table is not created during task deployment. If you select Auto Create, a table with the same name is created in the destination environment during task deployment.

    • Do Not Process: If the destination table does not exist, the system displays a message during submission, but you can still deploy the task. In this case, you must manually create the destination table in the production environment before the task can run.

    • Auto Create: You must Edit DDL statement. By default, Dataphin pre-fills the DDL statement for the selected table, and you can modify it. The DDL statement supports only the ${table_name} placeholder for the table name. At runtime, the system replaces this placeholder with the actual table name.

      If the destination table does not exist, the system first tries to create it by using the DDL statement. If the table creation fails, the deployment check fails. You can then modify the DDL statement based on the error message and try to deploy the task again. If the destination table already exists, the system does not execute the DDL statement.

    Note

    This parameter is available only in projects that use Dev-Prod mode.

    Data format

    You can select CSV or JSON.

    If you select CSV, you must also configure CSV import column delimiter and CSV import row delimiter.

    CSV import column delimiter (Optional)

    When you use StreamLoad to import data in CSV format, you can specify the column delimiter. The default delimiter is _@dp@_. If you use the default value, do not explicitly specify it here. If your data contains the _@dp@_ string, you must specify a custom delimiter.

    CSV import row delimiter (Optional)

    When you use StreamLoad to import data in CSV format, you can specify the row delimiter. The default delimiter is _#dp#_. If you use the default value, do not explicitly specify it here. If your data contains the _#dp#_ string, you must specify a custom delimiter.

    Batch write (Optional)

    If you Enable this option, the component writes data to the destination in batches. The system submits data based on the batch write size and number of rows per batch. This reduces the pressure of a single write operation and prevents oversized transactions. If you Disable this option, the component writes all data at once, which may consume more memory and increase the risk of write failures.

    Batch write size (Optional)

    Specifies the amount of data to write in a single batch. You can also set the number of rows per batch. During a write operation, the system commits the data when either of the specified limits is reached, whichever comes first. The default value is 100 MB.

    Number of rows per batch (Optional)

    The default value is 500,000. The component writes data by using a batching strategy, which depends on the number of rows per batch and batch write size parameters.

    • When the accumulated data reaches either of the configured limits (batch write size or number of rows), the system considers the batch full and immediately writes the batch to the destination.

    • Set the batch write size to 100 MB. You can adjust the upper limit for the number of rows per batch based on the actual size of a single record. To maximize the benefits of batch writing, set a large value. For example, if a single record is about 1 KB, you can set the batch write size to 100 MB and the number of rows per batch to a value greater than 102,400 (100 MB / 1 KB), such as 500,000. With this configuration, a batch write operation triggers whenever the accumulated data size reaches 100 MB.

    Preparatory statement (Optional)

    Specifies an SQL script to execute on the database before data import.

    For example, to ensure continuous service availability, you can use a preparatory statement to create a target table named Target_A before the current step writes data to it. After the step writes the data, you can use a post-execution statement to rename the live service table Service_B to Temp_C, rename Target_A to Service_B, and then delete Temp_C.

    Post-execution statement (Optional)

    Specifies an SQL script to execute on the database after data import.

    Field mapping

    Input fields

    Displays the input fields based on the output of the upstream component.

    Output fields

    Displays the output fields. You can perform the following operations:

    • Manage fields: Click Manage fields to select output fields.

      image

      • Click the gaagag icon to move fields from Selected input fields to Unselected input fields.

      • Click the agfag icon to move fields from Unselected input fields to Selected input fields.

    • Batch add: Click Batch add to configure fields in bulk by using the JSON, TEXT, or DDL format.

      • To configure fields in JSON format, see the following example:

        // Example:
        [{
          "name": "user_id",
          "type": "String"
         },
         {
          "name": "user_name",
          "type": "String"
         }]
        Note

        The name parameter specifies the name of the field to import, and the type parameter specifies the data type of the field. For example, "name":"user_id","type":"String" specifies that you import the field named user_id and set its data type to String.

      • To configure fields in TEXT format, see the following example:

        // Example:
        user_id,String
        user_name,String
        • The row delimiter separates the information for each field. The default is a line feed (\n). A semicolon (;) and a period (.) are also supported.

        • The column delimiter separates the field name and the field type. The default is a comma (,).

      • To configure fields in DDL format, see the following example:

        CREATE TABLE tablename (
            id INT PRIMARY KEY,
            name VARCHAR(50),
            age INT
        );
    • New output field: Click + New output field, enter a Field name, and select a Type as prompted. After you configure the current row, click the image icon to save the settings.

    Mapping method

    Specifies how to map input fields from the source table to output fields in the destination table. The available methods are map by name and map by position.

    • map by name: Maps fields that have the same name.

    • map by position: Maps fields based on their order. Use this method when the field names in the source and destination tables do not match but you need to map the data based on column position.

  9. Click OK to complete the property configuration for the SelectDB output component.