All Products
Search
Document Center

DataWorks:Create an ad hoc query

Last Updated:Mar 26, 2026

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.

  1. Log in to the DataWorks console. In the top navigation bar, select your region.

  2. 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.

  3. 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.
  4. Move the pointer over the image.png icon and select Folder.

  5. 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 (.).
  6. 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.

  1. In the Ad Hoc Query pane, right-click the folder you created and choose Create Node > ODPS SQL.

  2. In the Create Node dialog box, enter a Name and set the Path.

  3. Click Confirm.

  4. 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.

    ad hoc query editor

  5. Click the 执行 icon in the toolbar to run the node and view results.