The SQL script component allows you to write SQL statements in the SQL script editor.

Configure the component

You can configure the SQL script component only in the Machine Learning Platform for AI (PAI) console. The following table describes the parameters for the component.
Parameter Description
Input Source The name of the input table.
SQL script The SQL script that is used to implement the required feature. The last SQL statement of the SQL script must be a SELECT statement that is used to obtain the input data for the component. For more information about the syntax of SQL statements, see MaxCompute SQL overview.

Example

  1. In the left-side navigation pane, click Data Source/Target. Then, drag the Read MaxCompute Table component to the canvas and click the component. In the right-side panel, set the parameters. Name of the input table
    • If the input table is a partitioned table, the system automatically selects Partition. You can select or specify only one partition. If you clear Partition or do not specify a partition, the full table is used as the input.
    • If the input table is a non-partitioned table, the Partition check box is dimmed.
  2. In the left-side navigation pane, click Tools. Then, drag the SQL script component to the canvas and connect the Read MaxCompute Table component to the SQL script component.
  3. Click the SQL script component on the canvas. In the SQL script section of the Parameters Setting panel, enter the SQL script that is used to implement the required feature. Enter an SQL scriptDescription of the SQL script component:
    • The component supports one to four inputs and one output.
    • Input tables are automatically mapped to tables t1 to t4. You can directly use ${t1} or ${t2} without the need to specify the table names.
    • You can execute various SQL statements in the middle of an SQL script. However, the last statement must be a SELECT statement. The output table contains the execution result of the SELECT statement.
    • The sample SQL script is used to collect the number of rows in the input tables.
  4. In the left-side navigation pane, click Data Source/Target. Then, drag the Write MaxCompute Table component to the canvas and click the component. In the Table Selection panel, set the New Table Name parameter. Then, the system creates a table based on the name that you specified. If you want to write data to a partitioned table, you must first create the table. Write MaxCompute Table
  5. Connect the SQL script component to the Write MaxCompute Table component. Then, click Run in the top toolbar. Sample experiment
  6. After the experiment is executed, right-click the Write MaxCompute Table component on the canvas and select View Data to view the data that is written.