All Products
Search
Document Center

DataWorks:Debug a code snippet: Quickly run a code snippet

Last Updated:Aug 14, 2023

DataWorks provides the quick run feature to allow you to quickly run the code snippet that you select on the configuration tab of a node. You can use this feature to test whether a code snippet is correctly written. This topic describes how to quickly run a code snippet of a node.

Prerequisites

An ODPS SQL or EMR Hive node is created and the code of the ODPS SQL or EMR Hive node is written.

Limits

  • Only ODPS SQL and EMR Hive nodes support the quick run feature.

  • You can use the quick run feature to quickly run the code only of nodes that are not running. If the code of a node is being executed, the quick run icon Run icon is not displayed on the left side to the code line of the node.

Precautions

The code of the ODPS SQL or EMR Hive node is run when you use the quick run feature. You are not charged for scheduling resources but are charged for compute engine instances that you use. For information about the billing details of the compute engine instances, see the topics of the billing rules of the Alibaba Cloud services to which the compute engine instances belong in the documentation.

Procedure

  1. Go to the DataStudio page.

    Log on to the DataWorks console. In the left-side navigation pane, choose Data Modeling and Development > DataStudio. On the page that appears, select the desired workspace from the drop-down list and click Go to DataStudio.

  2. Find the ODPS SQL or EMR Hive node and double-click the node to go to the configuration tab of the node.

    In the left-side navigation pane, click Scheduled Workflow, Manually Triggered Workflows, or Ad Hoc Query, find the ODPS SQL or EMR Hive node that you create, and then double-click the ODPS SQL or EMR Hive node to go to the configuration tab of the node.

  3. Quickly run the code that you select and view the result.

    In this section, the ODPS SQL node is used. Run a code snippet

    1. Select the code that you want to run.

      In the SQL code section of the configuration tab of the ODPS SQL node, move the pointer over a line of code that you want to run. The system automatically highlights the complete code snippet to which the line of code belongs.

    2. Run the code.

      Note
      • You can use the quick run feature to quickly run the code only of nodes that are not running. If the code of a node is being executed, the quick run icon Run icon is not displayed on the left side to the code line of the node.

      • Description of the resource group that is used to run the selected code snippet by using the quick run feature:

        • The code of the ODPS SQL or EMR Hive node is run when you use the quick run feature. You are not charged for scheduling resources but are charged for compute engine instances that you use. For information about the billing details of the compute engine instances, see the topics of the billing rules of the Alibaba Cloud services to which the compute engine instances belong in the documentation.

        • The resource group that you use to quickly run the current code snippet is the resource group that is used for the most recent execution of the code of the ODPS SQL node. You can run the code of the ODPS SQL node by clicking the quick run icon Run icon, run icon Run icon, or advanced run icon Run with Parameters icon in the top toolbar of the configuration tab of the node.

        • The first time you run the code of the ODPS SQL node, you must select a resource group for scheduling based on your business requirements. If existing resource groups do not meet your business requirements, you can create a resource group. For more information, see Create and use an exclusive resource group for scheduling.

        • If you want to change the resource group that is used to run the code of the ODPS SQL node, click the Run with Parameters icon icon.

      • The first time you quickly run a code snippet, you must specify values for variables if the code snippet contains variables. The system saves the specified values for subsequent operations. If you want to change the specified values of the variables, click the Run with Parameters icon icon. For more information about how to specify a value for a variable, see Supported formats of scheduling parameters.

      You can use one of the following methods to run the code of the ODPS SQL node:

      • Click the quick run icon Run icon on the left side to the code line of the ODPS SQL node.

      • Run the code of the ODPS SQL node by using a shortcut key.

        • Windows operating system: Press Ctrl+Enter.

        • macOS: Press Cmd+Enter.

      After the execution of the code of the ODPS SQL node is complete, you can view the execution result. If an unexpected result is returned, modify the code snippet.