Quick start
The Data Analysis feature in DataWorks provides tools for analyzing and sharing data. You can connect to various data sources, run SQL queries, and use spreadsheets to manage daily data extraction and analysis. This topic shows you how to use the MaxCompute engine with SQL Query to analyze a public dataset, introducing the basic features of Data Analysis.
Features
DataWorks provides public datasets for various business scenarios. This topic uses the Alibaba e-commerce dataset (the commerce_ali_e_commerce table) to help you get started with the Data Analysis feature.
Alibaba e-commerce dataset: Contains statistics on Taobao order details from different time periods.
The table records random user actions, including clicks, purchases, cart additions, and favorites, from approximately 1 million users between
November 25, 2017andDecember 3, 2017.Number of users:
987,994. Number of products:4,162,024. Total number of actions:100,150,807.
To learn more about the Data Analysis feature, see Data Analysis.
Public datasets are available in the following regions: China (Shanghai), China (Beijing), China (Shenzhen), China (Hangzhou), China (Chengdu), China (Zhangjiakou), and China (Ulanqab).
Permissions
You must have the required permissions for Data Analysis. For a complete list of permissions, see Permissions of preset roles for Data Analysis.
To grant a role to a user, see Add a workspace member and manage their role and permissions.
Prerequisite
You have configured a MaxCompute data source. For more information, see Bind MaxCompute compute resources.
Access SQL Query
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Click Go to DataAnalysis to open the Data Analysis page. In the left-side navigation pane, click SQL Query.
Step 1: Query data
This example uses the Alibaba e-commerce dataset (commerce_ali_e_commerce), which contains Taobao order details from different time periods. You will use the SQL Query feature to query and sort the dataset, and then analyze and share the query results.
Go to SQL Query.
You can access SQL Query in the following ways:
On the Data Analysis homepage, in the Shortcuts section, click SQL Query to go to the SQL Query page.
In the Data Analysis module, click SQL Query in the left-side navigation pane to go to the SQL Query page.
Create a Temporary File.
In the left-side pane, click the
icon next to My Files, and select Create File to create an SQL query file as prompted. For more ways to create SQL query files, see SQL Query.NoteThis topic uses the public datasets provided by DataWorks. When you access SQL Query for the first time, you can click Go to DataAnalysis > MaxCompute on the Welcome Page to generate a query for the Alibaba e-commerce dataset (
commerce_ali_e_commerce).For more public datasets, go to and view them in the Public Data directory.
Select the SQL execution Data Source.
On the temporary file editing page, click the
icon in the upper-right corner to select the workspace, engine type, and data source for the current SQL query. In this example, select the MaxCompute data source that you have created.Write and run the task code.
In the code editor of the temporary query file, write and run the following code.
Based on the public dataset, count and sort the number of Taobao orders during different time periods.
SET odps.namespace.schema = true ; SELECT CASE WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 0 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 3 THEN '0:00-3:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 4 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 7 THEN '4:00-7:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 8 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 11 THEN '8:00-11:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 12 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 15 THEN '12:00-15:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 16 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 19 THEN '16:00-19:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 20 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 23 THEN '20:00-23:00' END AS order_time ,COUNT(*) AS order_count FROM bigdata_public_dataset.commerce.commerce_ali_e_commerce GROUP BY order_time ORDER BY COUNT(*) DESC LIMIT 100 ;View the query results.
Click the
icon to run the SQL code.The query results table contains two columns: Order Time and Order Count, with 6 rows of data.
Order Time
Order Count
20:00-23:00
376582343
16:00-19:00
226263195
12:00-15:00
222907927
08:00-11:00
186475432
00:00-03:00
95900494
04:00-07:00
57393434
Step 2: Analyze data
On the query result page from Step 1, click the
icon in the left-side navigation pane, and then click the
edit icon to go to the chart editing page. You can edit chart information based on your business requirements.
Example 1: View the total number of orders during different time periods
Rename the chart.
Double-click the name above the chart to rename it.
Style settings.
Click Style Settings on the right side, select Change Chart > Stacked Bar Chart, and click Change.
In Global Settings > Chart Information, select Detailed to display Axis Titles. You can also modify these settings on the Chart Style tab.
Data settings.
Click Data Settings on the left side, and drag Order Time to Y Axis and Order Count to X Axis.
NoteThe default Aggregation method for X Axis is Sum. You can adjust this based on your business requirements.
Example 2: View the distribution of orders during different time periods
Rename the chart.
Double-click the name above the chart to rename it.
Style settings.
Click Style Settings on the right side, select Change Chart > Pie chart, and click Change.
In Global Settings > Chart Information, select Detailed.
Data settings.
Click Data Settings on the left side, and drag Order Time to Category and Order Count to Value.
NoteThe default Aggregation method for Value is Sum. In the drop-down menu for Value, select . You can also adjust this based on your business requirements.
You can also use the spreadsheet feature provided by DataWorks to display and analyze data. For more information, see Spreadsheet.
Step 3: Share data
You can share SQL query results with other users as spreadsheets to enable online data sharing.
Export the query results.
On the query result page from Step 1, click the
icon on the right side, and select Workbook and share from the drop-down menu.Go to the Spreadsheet page.
On the Spreadsheet page, you can synchronize query results. For more information about spreadsheet operations, see Spreadsheet operations.
Share the query results.
Click Share in the upper-right corner of the page to share the data with specific users. Shared users can access the result table through a URL or an access code. You can specify whether shared users can edit or only view the result table.
Next steps
For more information about SQL Query, see SQL Query.
For more information about spreadsheet operations, see Spreadsheet operations.