Analyze public big data and AI datasets
This tutorial uses a public dataset to show how to perform simple data analysis in DataWorks. The detailed steps use free trial resources as an example. You can follow similar steps with paid resources.
Tutorial overview
DataWorks is a unified, end-to-end big data development and administration platform. It works with various big data engines to provide solutions for data warehouses, data lakes, and data lakehouses.
This tutorial guides you through a quick big data analytics task. You will use DataWorks and the cloud-native big data computing service MaxCompute. The task uses public big data and AI datasets, such as data from Taobao, Fliggy, AliMusic, GitHub, and TPC. You will learn the DataWorks interface and its basic data analytics features. For more information about the end-to-end data capabilities of DataWorks, including modeling, integration, development, and administration, see the official documentation.
What you will learn
-
Learn about the basic DataWorks interface, including how to log on to the console, create a data source, and navigate to feature modules.
-
Learn how to perform simple big data analytics operations in DataWorks and understand its data analytics capabilities.
|
Difficulty |
Low |
|
Time required |
30 minutes |
|
Alibaba Cloud products used |
|
|
Costs |
|
Prepare the environment and resources
-
Activate DataWorks.
-
Visit Alibaba Cloud Free Trial. Click the Login/Register button in the upper-right corner of the page and follow the on-screen instructions to log on to your Alibaba Cloud account, register for a new account, or complete identity verification. You must complete individual or enterprise identity verification as required for the product you want to try.
-
After you log on, you are redirected to the Request a free trial of DataWorks page. Find the DataWorks product and click Try Now.
-
In the purchase panel for the trial version of the DataWorks product, select China (Shanghai) as the region, select the Terms of Service checkbox, and click Confirm Order And Pay.
-
-
Prepare the MaxCompute environment.
-
This tutorial also requires MaxCompute. You can request a free MaxCompute resource plan to complete this tutorial. To request the resource plan, go to the Request Free Trial for MaxCompute page. For more information about the supported regions and free quota of the resource plan, see Free trial quota for new MaxCompute users.
Note: If you have previously applied for a MaxCompute free trial, log on to the MaxCompute console and check whether the China (Shanghai) region is activated. If the China (Shanghai) region is not activated, you can click Activate MaxCompute Now on the welcome page to activate it.
-
If you are not eligible for a free trial of MaxCompute, you can activate a pay-as-you-go version of MaxCompute. For more information about billing, see Billing overview.
-
Create a MaxCompute project
-
Log on to the MaxCompute console. In the upper-left corner, select a region. This tutorial uses the China (Shanghai). In the left navigation pane, click Project management. On the Project Management page, click Create Project.
-
Configure the project on the Create Project page. The following table describes the key settings.
Parameter
Description
Project name
Specify a project name. This tutorial uses doc_test_000.
NoteProject names must be globally unique. If the name already exists, change it as prompted.
Compute resource billing method
This tutorial selects Pay-as-you-go.
Important. The free trial resource deduction package can offset only pay-as-you-go resource usage, so this tutorial selects Pay-as-you-go.
Default quota
Allocates compute resources. This tutorial selects Default pay-as-you-go quota.
Single SQL consumption limit
This tutorial leaves the setting blank. It sets an upper limit on the cost of a single SQL query, measured as scanned data (GB) multiplied by complexity. This optional setting is recommended when you select Pay-as-you-go billing to avoid unexpectedly high charges for a single SQL query. We also recommend setting real-time spending alerts to monitor usage. For more information, see Consumption monitoring alert.
Data type
MaxCompute supports 1.0 data types, 2.0 data types, and Hive-compatible types. This tutorial selects 2.0 data types.
Storage encryption
Specify whether to enable data encryption for the MaxCompute project. For more information, see Storage encryption.
This tutorial selects No encryption.
-
After configuring the settings, click Determine to create the project.
Add a MaxCompute data source
This tutorial uses the China (Shanghai) default workspace.
-
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 Management Center.
-
On the Management Center page, click in the left navigation pane, then click Add Connection. In the dialog box, select the MaxCompute data source. For instructions on configuring it, see Associate a MaxCompute compute resource.
-
After configuring the settings, click Complete Creation. This adds the data source.
Try querying data
This tutorial uses the Alibaba e-commerce dataset (bigdata_public_dataset.commerce.commerce_ali_e_commerce).The dataset comes from the Tianchi Alibaba Mobile Recommendation Algorithm Challenge and contains one million anonymized behavior records, including page views, purchases, additions to cart, and favorites.
DataWorks provides datasets that you can use to explore its development and analytics features. You can run simple SQL queries, analyze data, generate results, and share them with colleagues.
-
Log on and open the DataWorks console. In the upper-left corner, select a region. This tutorial uses the China (Shanghai).
-
Log on to the DataWorks console. In the left navigation pane, click , and then select Public Dataset.
-
Click the Alibaba e-commerce dataset card to open its Alibaba e-commerce dataset details page.
-
Click Start Analysis in the upper-right corner and select an engine type. This tutorial uses MaxCompute.
-
A new query page opens in DataWorks SQL Query with the public dataset's default SQL query. Click in the upper-right corner of the SQL query file, and set the workspace and engine in the dialog box.
-
You can now write SQL queries in the file. When finished, click Run on the SQL query file toolbar. After the query succeeds, the results appear below the file.
The Appendix: Sample SQL queries section below provides sample SQL queries for data analysis.
Advanced analysis: Create a card
-
Click on the left side of the query results. DataWorks automatically creates a visualization of the results shown in the table.
NoteOn your first use, click Try Now and follow the prompts to enable Advanced Analysis.
The query results then appear as a chart. For example, the system may generate a bar chart of Total page views by time period, with Time period on the X-axis and Page views (sum) on the Y-axis. Click the Edit icon or the Save button in the upper-right corner to adjust or save the chart.
-
If the generated visualization does not meet your needs, click in the upper-right corner of the chart to open the chart editor. This tutorial uses axis titles as an example to show how to edit the chart.
-
Click in the upper-right corner of the chart to save the result persistently and share it.
After saving the card, click DataAnalysis in the leftmost navigation pane of the page to view all saved cards.
Advanced analysis: Create a report
After saving analysis results as DataWorks cards, you can use Advanced Analysis reports to arrange the cards into a report with charts, descriptions, and a logical flow, and share it with colleagues.
-
Click the DataAnalysisIn the left navigation pane of the page, click Report to open the
-
Click Create Report and select the analysis result cards as prompted.
-
Configure the report content and theme, then click Create in the upper-right corner to create the report.
The report management page shows existing reports as card thumbnails. You can sort them with the Sort by update date drop-down list in the upper-left corner or click + Create Report in the upper-right corner to create a report.
-
On the report list page, hover over the report you want to share and click Share in the upper-right corner. Follow the prompts to obtain a sharing link and send it to the intended recipients.
Click here for a sample link to a shared analysis report.
Appendix: Sample SQL queries
-
Trends in user shopping behavior over time
SET odps.namespace.schema = TRUE; SELECT CAST(SUBSTR(behavior_time,12) AS BIGINT) AS time_period ,CASE WHEN behavior_type = '1' THEN 'Product page view' WHEN behavior_type = '3' THEN 'Add to cart' WHEN behavior_type = '4' THEN 'Purchase' ELSE behavior_type END AS user_action ,COUNT(DISTINCT user_id) AS user_count FROM bigdata_public_dataset.commerce.commerce_ali_e_commerce WHERE behavior_type IN ('1','3','4') GROUP BY time_period ,user_action order by time_period asc; -
Page views by time period
SET odps.namespace.schema = true; set odps.task.sql.sqa.enable=false; SELECT CASE WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 0 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 3 THEN '00:00-03:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 4 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 7 THEN '04:00-07:00' WHEN CAST(SUBSTR(behavior_time,12) AS BIGINT) >= 8 AND CAST(SUBSTR(behavior_time,12) AS BIGINT) <= 11 THEN '08: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 time_period ,COUNT(1) AS page_view_count FROM bigdata_public_dataset.commerce.commerce_ali_e_commerce WHERE behavior_type = '1' GROUP BY time_period ORDER BY time_period ASC LIMIT 100; -
Top 10 best-selling product categories
SET odps.namespace.schema = true; SELECT item_category as category_id,COUNT(DISTINCT item_id) AS product_count FROM bigdata_public_dataset.commerce.commerce_ali_e_commerce WHERE behavior_type = '4' group by item_category order by product_count desc limit 10;
Clean up
After you complete the tutorial, clean up the test data and trial resources promptly.
-
Clean up MaxCompute resources.
This tutorial uses the MaxCompute compute engine. After you complete the tutorial, release the MaxCompute resources immediately if you no longer need them. Otherwise, you will continue to be charged. For more information, see Release resources.
-
Clean up DataWorks resources.
This tutorial uses the DataAnalysis feature of the Basic Edition of DataWorks. You are not charged after the data analysis tasks in the Basic Edition are complete. If you used other DataWorks features and ran other auto triggered tasks on a DataWorks resource group, pause the tasks immediately to avoid wasting resources.
You can go to the Auto Triggered Task page in the Operation Center to pause tasks. For more information, see Manage auto triggered tasks.