DataWorks DataStudio's ad hoc query feature allows you to execute SQL statements within a MaxCompute project linked to your DataWorks workspace.
Prerequisites
The MaxCompute data source must be created and attached to Data Development (DataStudio).
Before developing MaxCompute tasks or creating related nodes, you must first establish a MaxCompute data source within the DataWorks workspace and attach it to Data Development (DataStudio), which serves as the underlying engine for developing MaxCompute tasks. For more information, see Create a MaxCompute data source and Environment preparation.
Enter ad hoc query
-
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose . On the page that appears, select the desired workspace from the drop-down list and click Go to Data Development.
-
In the left-side navigation pane, click the
icon.
-
In the Ad Hoc Query panel, right-click Ad Hoc Query and select
. -
In the Create Node dialog box, enter the Name.
NoteThe node name must not exceed 128 characters.
-
Click Confirm.
Execute SQL
You can now execute MaxCompute-supported SQL statements in the newly created ad hoc query node. For more information, see SQL overview.
-
When executing MaxCompute tasks, a cost estimate is provided. This estimate is calculated by MaxCompute and is indicative only. The final cost will be reflected in your bill. For billing details, see MaxCompute billable items and billing method.
-
If an error occurs during cost estimation, it may be due to a non-existent table or insufficient permissions. You can disregard this error temporarily and address it after running the node based on the specific error message received.
For instance, to execute a DDL statement for table operations, input the table creation statement and click .
create table if not exists sale_detail
(
shop_name string,
customer_id string,
total_price double
)
partitioned by (sale_date string,region string);
-- Create a partitioned table sale_detail
To view the cost estimate for this execution, click the Run option. In the Parameter pop-up, select the Run Resource Group and click Run.
The execution details and results can be viewed in the Runtime Log section at the bottom of the configuration tab. If the SQL statement executes successfully, the result will display as OK.
This method can also be used to execute SELECT syntax.