Create a database SQL task

更新时间:
复制 MD 格式

Create a database SQL task to run SQL statements against external data sources in Dataphin.

Limitations

  • Stored procedures are supported but not validated or parsed.

  • Executing a database SQL task requires data source execution permissions. Table-level permission checks are not supported.Apply for, renew, and return data source permissions.

  • MySQL and Oracle data source SQL tasks cannot trigger data source quality rules.Create data quality rules for a Dataphin table.

  • Only sample data can be downloaded from query results.

  • Offline computing template nodes do not support the database SQL task type.

  • In projects that use the Dev-Prod mode, if you use a data source configured only for the production environment, running backfill or other operations in the development environment may alter production data. Use with caution.

Procedure

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

  2. In the top navigation bar of the Develop page, select a Project. If your project is in Dev-Prod mode, you must also select an environment.

  3. In the left-side navigation pane, choose Data Processing > Compute Task. In the Compute Task list, click the image icon and choose Database SQL.

  4. In the Create Database SQL Task dialog box, configure the following parameters.

    Parameter

    Description

    Basic information

    Task name

    Enter a name for the compute task.

    The name can be up to 256 characters long and cannot contain vertical bars (|), forward slashes (/), backslashes (\), colons (:), question marks (?), angle brackets (<>), asterisks (*), or double quotation marks (").

    Scheduling type

    Select a scheduling type:

    • Periodic task: Runs automatically on a recurring schedule.

    • Manual task: Must be triggered manually.

    Select directory

    Select the directory to store the task.

    To create a directory, click New Folder:

    1. Above the compute task list, click the image icon to open the New Folder dialog box.

    2. In the New Folder dialog box, enter a folder Name and, if necessary, select its location in the Select Directory list.

    3. Click OK.

    Use template

    To use a code template, turn on the Use Template switch, and then select a template and a template version. By default, the latest version of the selected template is used.

    Template code is read-only — configure only the template parameters.Create an offline computing template.

    Note

    If a database SQL task that uses an AnalyticDB for PostgreSQL, StarRocks, Doris, SelectDB, or GaussDB (DWS) data source references an offline computing template, you cannot change the task type.

    Description

    Enter a brief description of the task, up to 1,000 characters.

    Data source configuration

    Data source type

    Select the data source type. Supported types are listed in the Offline Development-Database SQL column in Data sources supported by Dataphin.

    With a template, the data source type is locked to the template's type.

    Data source

    Select a data source, or click + New Data Source to create one.

    With a template, the data source defaults to the template's data source but can be changed.

    Catalog

    Required for Presto and Trino data sources.

    Database/Schema

    If the data source type is MySQL, PostgreSQL, AnalyticDB for PostgreSQL, Oracle, Presto, GaussDB (DWS), Microsoft SQL Server, ClickHouse, Hologres, Doris, openGauss, StarRocks, DM, OceanBase (Oracle tenant mode), SelectDB, Trino, PolarDB-X 2.0, or Lindorm, you must configure the Database/Schema after you configure the data source.

    With a template, the Database/Schema defaults to the template's schema but can be changed.

  5. Click OK.

  6. In the code editor on the task tab, write the code for the database SQL task. Database SQL tasks support cross-node output parameters.Assign a value to a cross-node output parameter and Best practices for cross-node parameters. After writing the code, click Run above the code editor.

  7. On the right sidebar, click Properties. In the Properties panel, configure the task's Basic Information, Parameters, scheduling properties (for periodic tasks), scheduling dependencies (for periodic tasks), runtime configuration, and resource configuration.

  8. On the task tab, save and commit the current task.

    1. Click the image icon above the code editor to save the code.

    2. Click the image icon above the code editor to commit the code.

  9. On the Commit Details page, verify the Content to Commit and Pre-check results, and enter a commit description.Commit an offline compute task.

  10. Click Confirm and Commit.

What to do next