Ad hoc queries let you write and run code directly in the DataStudio development environment — without deploying anything to production. Use them to test SQL logic, verify code behavior, or spot-check query results.
Prerequisites
Before you begin, ensure that you have:
A DataWorks workspace
Permission to use DataStudio in that workspace
Create a folder
Organize your ad hoc queries in folders before creating nodes. DataWorks supports nested folders — you can place a new folder inside an existing one.
Log in to the DataWorks console. In the top navigation bar, select your region.
In the left-side navigation pane, choose Data Development and Governance > Data Development. Select your workspace from the drop-down list and click Go to Data Development.
On the DataStudio page, click Ad Hoc Query in the left-side navigation pane.
Click the
icon in the lower-left corner to show or hide the navigation pane.Move the pointer over the
icon and select Folder.In the Create Folder dialog box, enter a Folder Name and set the Location.
The node name cannot exceed 128 characters in length and can contain only letters, digits, underscores (
_), and periods (.).Click Create.
Create an ad hoc query node
The Ad Hoc Query pane supports these node types: EMR Hive, ODPS SQL, EMR Spark SQL, EMR Presto, EMR Impala, Shell, AnalyticDB for PostgreSQL, AnalyticDB for MySQL, and Data Lake Analytics. The creation steps are the same for all node types. The steps below use ODPS SQL as an example.
In the Ad Hoc Query pane, right-click the folder you created and choose Create Node > ODPS SQL.
In the Create Node dialog box, enter a Name and set the Path.
Click Confirm.
On the configuration tab of the node, write your SQL code.
If multiple MaxCompute compute resources are associated with your workspace, select the one that matches your requirements before running the node. If the selected MaxCompute data source uses the default pay-as-you-go resource group, click the
icon in the toolbar to estimate the cost before running. Actual costs are reflected in your bill.
Click the
icon in the toolbar to run the node and view results.