Use ad hoc queries to test whether your code runs as expected or to troubleshoot code errors.
Background
To query data or test code in Data Studio (the development environment) without publishing it to the production environment, create an ad hoc query.
Create a folder
-
Go to the DataStudio page.
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Development.
-
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. -
Hover over the
icon and click Folder. -
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. This allows you to create a new folder inside an existing one.
-
-
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.
This topic uses an ODPS SQL node as an example.
-
On the Ad Hoc Query page, right-click a folder name and choose .
-
In the Create Node dialog box, enter a Node Name and select a Path.
- Click Confirm.
-
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 warninindicatorNote-
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, you can click the
icon in the toolbar before you run the statement to estimate the cost. The actual cost is determined by your bill.
-
-
Click the
icon in the toolbar to view the results.