All Products
Search
Document Center

MaxCompute:Develop and submit an SQL script

Last Updated:Feb 27, 2026

This topic describes how to write, configure, and run an SQL script in MaxCompute Studio.

Prerequisites

Write an SQL script

  1. In the Project tool window, click a project name, right-click scripts, and then choose New > MaxCompute SQL Script. Create an SQL script

  2. In the New MaxCompute SQL Script dialog box, configure the following parameters, and then click OK. Script name dialog box

    • Script Name: the name of the script.

    • MaxCompute Project: the MaxCompute project in which to write the SQL script. Click + to connect to another MaxCompute project. For more information, see Manage project connections.

  3. Write an SQL script in the editor. For more information about SQL syntax, see Overview of MaxCompute SQL. Sample script: Note:

    • Cross-project resource sharing is supported. For example, a script bound to Project A can access table1 in Project B.

    • MaxCompute Studio allows you to configure the SQL script editor. For more information, see Overview.

       CREATE TABLE table_5(
       col1 BIGINT,
       col2 BIGINT,
       col3 BIGINT,
       ds DATETIME
       );
    
       INSERT INTO TABLE table_5 VALUES (1, 2,3,DATETIME'2025-11-11 00:00:00');
    
       SELECT * FROM table_5 WHERE ds='${bizdate}';

Configure compilation parameters

Before submitting an SQL script, configure the compilation parameters in the toolbar above the editor.

Editor mode

OptionDescription
Statement ModeSeparates SQL statements with semicolons (;) and submits each statement individually to the MaxCompute server.
Script Mode (Recommended)Submits the entire script to the MaxCompute server at once for overall optimization. This is the latest development mode and provides better execution efficiency.

Type system

Configure this parameter to prevent compatibility issues when running SQL statements.

OptionDescription
Legacy TypeSystemMaxCompute V1.0 data type edition.
MaxCompute TypeSystemMaxCompute V2.0 data type edition.
Hive Compatible TypeSystemHive-compatible data type edition.

Execution mode

OptionDescription
Default VersionUses a stable version.
MaxQAEnables the MaxQA feature to run a job.
MaxCompute Query AccelerationEnables the MaxCompute Query Acceleration (MCQA) feature to run a job.
Rerun When Acceleration FailsReruns a job if query acceleration fails.

Run the script

  1. In the toolbar or sidebar, click the Run icon icon to submit the SQL script to the MaxCompute server.

    If the SQL script contains a variable such as ${bizdate}, a dialog box prompts for the variable value. For example, enter 2017-11-11 00:00:00 to query data in the corresponding partition.
  2. Review the estimated cost that IntelliJ IDEA displays, and then click OK in the Confirmation message. Cost confirmation Note:

    • To update the metadata used in the SQL script, such as tables and user-defined functions (UDFs), click the Refresh icon icon in the toolbar. Use this if MaxCompute Studio cannot detect the tables and functions in MaxCompute.

    • SQL scripts are compiled based on the metadata added in the Project Explorer window. If no errors are detected, the scripts are submitted to the MaxCompute server for execution.

    • Run logs are generated during execution. When SQL scripts run in MaxCompute, the job details tab appears with execution details.

    • To display cost estimation for SQL jobs, select Show sql cost confirm dialog when script submitted in the MaxCompute SQL configuration items.

  3. On the Result tab, view the execution results. If multiple statements are executed one by one, the result of each statement is displayed separately. Execution results