Help Center/ DataArts Studio/ User Guide/ DataArts Factory/ Usage Guidance/ Using Script Templates and Parameter Templates
Updated on 2023-05-05 GMT+08:00

Using Script Templates and Parameter Templates

Scenario

This function applies to the following scenarios:

  • Use a script template for a Flink SQL script.
  • During pipeline job development, use a Fink SQL script which uses a script template for the MRS Flink Job node and use a parameter template for Program Parameter of the MRS Flink Job node.
  • Use a script template in a single-task Flink SQL job.
  • Use template parameters in a single-task Flink JAR job.

    When you use a script template in a script, ensure that the SQL statement is in @@{Script template} format.

Prerequisites

A template has been created. If no template is available, create one by referring to Configuring a Template.

Using Templates

  • Use a script template for a Flink SQL script.
    1. In the navigation pane on the DataArts Studio console, choose Data Development > Develop Script.
    2. Right-click a script directory and select Create Flink SQL Script.
    3. Click Template. In the slide-out pane, select a template, for example, 412_mobna. You can select multiple templates.
      Figure 1 Using a script template

    4. Click Save to create the 412_test script.
  • During the development of a pipeline job, use the Flink SQL script which uses a script template for the MRS Flink Job node.
    1. In the navigation pane on the DataArts Factory console, choose Data Development > Develop Job.
    2. Right-click a job directory and select Create Job to create a batch processing job in pipeline mode.
    3. On the displayed data development page, drag an MRS Flink Job node to the canvas.
    4. Select Flink SQL job for Job Type and select the Flink SQL script for Script Path.

      After the script is selected, the template parameters and values used by the script are automatically displayed.

      Figure 2 Using the Flink SQL script

  • During the development of a pipeline job, use a parameter template in Program Parameter of the MRS Flink Job node.
    1. Set MRS Cluster.
    2. Program parameters are automatically displayed. Click Select Template and select a parameter template. You can also select multiple templates.
      The parameter names and values are automatically displayed.
      Figure 3 Using a parameter template for program parameters

  • Use a script template in a single-task Flink SQL job.
    1. In the navigation pane on the DataArts Factory console, choose Data Development > Develop Job.
    2. Right-click a job directory and select Create Job to create a real-time processing job in single-task Flink SQL mode.
    3. Click Template. In the slide-out pane, select a template, for example, 412_mobna. You can select multiple templates.
      Figure 4 Using a script template in a single-task Flink SQL job.

  • Use template parameters in a single-task Flink JAR job.
    1. In the navigation pane on the DataArts Factory console, choose Data Development > Develop Job.
    2. Right-click a job directory and select Create Job to create a real-time processing job in single-task Flink JAR mode.
    3. Set MRS Cluster.
    4. Program parameters are automatically displayed. Click Select Template and select a parameter template. You can also select multiple templates.
      The parameter names and values are automatically displayed.
      Figure 5 Using a script template in a single-task Flink JAR job.