Custom SQL

Updated at:

This topic describes how to use the Custom SQL operator and provides important notes.

Purpose

If the built-in operators do not meet your needs, you can write SQL statements to implement custom business logic.

Scenarios

Compute Link

Compute engine

Supported

Offline

MaxCompute

Yes

Hive

Yes

HiveStorage

Yes

RDS/MySQL

Yes

Usage instructions

Input node

Information about the output table of the ancestor node, including the table name and field names.

Table name identifier

The table name identifier is a placeholder in the SQL statement. At runtime, this placeholder is replaced with the actual table name from the output of the ancestor node.

image

Note

Use the ${} format for the table name identifier in the SQL statement. For example:

Select date -- Date ,sales -- Sales From ${table} Where sales >= 60

SQL script settings

Write the SQL script. An example is shown below:

image

Note

The script supports only SELECT statements. The query results of the SELECT statement are automatically written to a temporary table. Do not use statements such as CREATE, ALTER, or INSERT. Otherwise, the run will fail.

In the example, ${table} is automatically replaced with the actual name of the upstream input table at runtime.

Output fields

Configure the output fields for the operator. You can edit the fields manually or generate them automatically by parsing the SQL statement.

The SQL statement format required for automatic parsing is shown in the following figure:

image

These two lines are parsed into the following two fields: