Analyze public big data and AI datasets

Updated at:

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

  • DataWorks: A one-stop big data development and administration platform. After you create a data source and attach it in Data Development, you can use DataWorks to develop and schedule data development and administration tasks for the corresponding engine.

  • MaxCompute: An enterprise-grade Software as a Service (SaaS) cloud data warehouse for data analytics. It provides powerful computing and storage capabilities for massive amounts of data.

Costs

  • DataWorks:

    • Edition: Alibaba Cloud provides the Basic Edition of DataWorks for free.

    • Enhanced analysis: Alibaba Cloud provides a free quota. You are charged for usage that exceeds the free quota. For more information about billing, see Enhanced analysis billing.

  • MaxCompute: Alibaba Cloud Free Trial provides a free MaxCompute resource plan with a specific quota. You can use this resource plan to complete this tutorial for free. If your usage exceeds the free quota, you will be charged. For more information, see Billing overview.

Prepare the environment and resources

  1. Activate DataWorks.

    1. 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.

    2. After you log on, you are redirected to the Request a free trial of DataWorks page. Find the DataWorks product and click Try Now.

    3. 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.

  2. 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

  1. 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.

  2. 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.

    Note

    Project 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.

  3. After configuring the settings, click Determine to create the project.

Add a MaxCompute data source

This tutorial uses the China (Shanghai) default workspace.

  1. Log on to the DataWorks console. In the target region, click More > Management Center in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Management Center.

  2. On the Management Center page, click Data Sources > Data Sources 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.

  3. 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.

Note

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.

  1. Log on and open the DataWorks console. In the upper-left corner, select a region. This tutorial uses the China (Shanghai).

  2. Log on to the DataWorks console. In the left navigation pane, click Quick Start > DataWorks Gallery, and then select Public Dataset.

  3. Click the Alibaba e-commerce dataset card to open its Alibaba e-commerce dataset details page.

  4. Click Start Analysis in the upper-right corner and select an engine type. This tutorial uses MaxCompute.

  5. 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.

  6. 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

  1. Click on the left side of the query results. DataWorks automatically creates a visualization of the results shown in the table.

    Note

    On 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.

  2. 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.

  3. 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.

  1. Click the DataAnalysisIn the left navigation pane of the page, click Report to open the

  2. Click Create Report and select the analysis result cards as prompted.

  3. 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.

  4. 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.