DSW includes a built-in SQL File plugin for querying MaxCompute data sources with SQL—no Python code required.
Billing
SQL queries in DSW don't incur additional fees. You pay only for MaxCompute compute and storage costs.
Prerequisites
Before you begin, ensure the following:
MaxCompute is activated. For details, see Activate MaxCompute.
-
Your account must have MaxCompute project permissions. No additional authorization is required if you log in with your Alibaba Cloud account. For RAM users, follow the steps below to grant the necessary permissions.
Query MaxCompute data
-
Open the DSW development environment.
Log in to the PAI console.
In the left navigation pane, click Workspaces. On the workspace list page, click the target workspace name.
In the upper-left corner, select the region.
In the left navigation pane, choose Model Training > Data Science Workshop (DSW).
Optional: In the search box on the Data Science Workshop (DSW) page, enter an instance name or keyword to search for an instance.
In the Actions column for the target instance, click Open.
-
On the Notebook tab, on the Open page, click SQL File in the Text and terminal area to create a SQL query file.

-
Configure the MaxCompute data source:
Click the data source button in the upper-right corner of the main workspace area.
-
In the Data source settings panel, configure the parameters and click Select a node.
Parameter
Description
MaxCompute Endpoint
The endpoint for the region where your project is located. For details, see Endpoint. For example, the endpoint for China (Hangzhou) is
http://service.cn-hangzhou.maxcompute.aliyun.com/api.Tunnel Endpoint
The tunnel endpoint for the region where your project is located. For details, see Endpoint. For example, the endpoint for China (Hangzhou) is
http://dt.cn-hangzhou.maxcompute.aliyun.com.MaxCompute project
The MaxCompute project name.
-
Enter your query in the SQL editor and run it to view the results.
Run code: Click the Run button to the left of the SQL statement to run it directly. To run a specific selection, select part of the code and click
. After the run completes, view the results in the output area.Format code: Click the format button to reformat your SQL code.
-
View the query results.
After the SQL statement runs successfully, perform the following operations on the query results:
Feature
Illustration
Description
View table data

Displays the query results of the SQL statement.
Visualize results as charts

Supports visualizing query results as line charts, bar charts, horizontal bar charts, pie charts, and pivot tables. Drag fields to dimension or metric areas to create a chart, or click a field to change its data type or set an alias.
View the SQL for the results

Displays the SQL for the current query results. Supports copying and inserting it into the code editor.
View query operation logs

Displays the operation log for the current SQL statement. If the statement fails, click the Logview link in the log to troubleshoot.
References
To read MaxCompute data using Python, use PyODPS instead of SQL File. For more information, see Read and write MaxCompute tables with PyODPS.
