All Products
Document Center

DataWorks:Create an ad hoc query

Last Updated:Aug 14, 2023

Ad hoc query allows you to test your code in the development environment. This way, you can perform troubleshooting or check whether your code works as expected.

Background information

If you need to only query data and related SQL code, test whether the code is run as expected, or verify the correctness of the code in the development environment, you can create an ad hoc query. You do not need to deploy the data or SQL code to the production environment and use a desired compute engine in the production environment.

Create a folder

  1. Go to the DataStudio page.

    1. Log on to the DataWorks console.

    2. In the left-side navigation pane, click Workspaces.

    3. In the top navigation bar, select the region where the workspace resides. On the Workspaces page, find the workspace in which you want to create tables, and click Shortcuts > Data Development in the Actions column.

  2. On the left-side navigation submenu, click the Temporary query icon.
    You can click the Show icon icon in the lower-left corner to show or hide the left-side navigation submenu.
  3. On the Temporary query tab, move the pointer over the Create icon icon and select Folder.
  4. In the New folder dialog box, enter a name for the folder in the Folder name field and configure the Destination folder parameter.
    • The folder name must be 1 to 128 characters in length and can contain letters, digits, underscores (_), and periods (.).
    • DataWorks supports multi-level folders. You can save a newly created folder under another folder that already exists.
  5. Click New.

Create an ad hoc query node

On the Temporary query tab, you can create a variety of ad hoc query nodes, such as EMR Hive, ODPS SQL, EMR Spark SQL, EMR Presto, EMR Impala, Shell, AnalyticDB for PostgreSQL, AnalyticDB for MySQL, and Data Lake Analytics nodes.

In this example, create an ODPS SQL node.

  1. On the Temporary query tab, right-click the folder you created and choose New Node > ODPS SQL.
  2. In the Create Node dialog box, configure the Name and Path parameters.
    Note The node name must be 1 to 128 characters in length and can contain letters, digits, underscores (_), and periods (.).
  3. Click Confirm.
  4. On the node configuration tab that appears, enter an SQL query statement.
    Ad-hoc query
    • If the current workspace is bound to multiple MaxCompute compute engines, you must select a desired MaxCompute engine instance before you submit the query statement for execution.
    • The selected MaxCompute engine instance may use a default resource group that is charged in pay-as-you-go mode. In this case, you can click the Cost Estimation icon icon in the toolbar to estimate the cost of this operation. The actual cost is included in your bill.
  5. Click the Run icon icon in the toolbar to view the query result.