Create an ad hoc query

更新时间:
复制 MD 格式

Ad hoc queries let you verify code behavior and troubleshoot errors without publishing to the production environment.

Background

To query data or test code in Data Studio (the development environment) without publishing to the production environment, create an ad hoc query.

Create a folder

  1. Go to the DataStudio page.

    Log on to the DataWorks console. In the target region, click Data Development and O&M > Data Development in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Development.

  2. In the left-side navigation pane, click Ad Hoc Query.

    You can click the 展开 icon in the lower-left corner to expand or collapse the left-side navigation pane.

  3. Hover over the image.png icon and click Folder.

  4. In the New folder dialog box, enter a Folder name and select a Location.

    Note
    • Folder names can be up to 128 characters long and can contain uppercase letters, lowercase letters, Chinese characters, digits, underscores (_), and periods (.).

    • DataWorks supports nested folders, so you can create a new folder inside an existing one.

  5. Click Create.

Create an ad hoc query node

On the Ad Hoc Query page, you can create EMR Hive, ODPS SQL, EMR Spark SQL, EMR Presto, EMR Impala, Shell, AnalyticDB for PostgreSQL, AnalyticDB for MySQL, and Data Lake Analytics nodes.

The following example uses an ODPS SQL node.

  1. On the Ad Hoc Query page, right-click a folder name and choose Create Node > ODPS SQL.

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

  3. Click Confirm.
  4. On the node editor page, enter an SQL query statement.

    For example, enter the following SQL query:

    --odps sql
    --*******************************************************************************
    --author:xxx
    --create time:2019-07-16 19:27:34
    --*******************************************************************************
    SELECT * FROM warninindicator
    Note
    • If your workspace has multiple MaxCompute computing resources bound to Data Studio, select the required resource before running the query.

    • If the selected MaxCompute engine instance uses a default pay-as-you-go resource group, click the 成本估计 icon in the toolbar before running the statement to estimate the cost. Actual costs are based on your bill.

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