You can use the ad hoc query feature provided by DataWorks DataStudio to execute SQL statements in a MaxCompute project associated with your DataWorks workspace.
Create an ad hoc query node
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 of the DataStudio page, click the icon.
In the Ad Hoc Query pane, right-click Ad Hoc Query and choose
.In the Create Node dialog box, configure the Name parameter.
NoteThe node name cannot exceed 128 characters in length.
Click Confirm.
Execute SQL statements
After the ad hoc query node is created, you can execute SQL statements supported by MaxCompute in the node. For more information, see Overview of MaxCompute SQL.
For example, to Table operations, enter the following statement and click the icon in the top toolbar of the configuration tab of the node.
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 named sale_detail.
You can view the estimated cost for the statement execution. In detail, you can click the Run icon in the top toolbar, select a resource group that you want to use in the Parameters dialog box, and then click Run. In the Estimate MaxCompute Computing Cost dialog box, you can view the estimated cost.
View the execution details and result in the result tab of the lower part of the configuration tab. If the SQL statement is successfully executed, the result is shown as OK. If the SQL statement is successfully executed, the result is shown as OK.
You can execute SQL statements that follow the SELECT syntax in the same way.