This tutorial shows you how to use DataWorks and MaxCompute to develop and analyze a data warehouse. You will use a case study to experience the features of Data Integration, Data Development, and Operation Center in DataWorks.
Case study overview
To better formulate business strategies, you need to obtain basic profile data of website user groups from their online behavior. This data includes geographic and social attributes. This allows for scheduled profile analysis at specific times, which helps you refine website traffic operations. You can use the combination of DataWorks and MaxCompute to perform operations such as data synchronization, data transformation, data management, and data consumption.
To follow this tutorial, read Tutorial objectives and design to understand the overall flow of the user persona analysis.
Notes
Ensure your account has the permissions to activate and purchase services. An Alibaba Cloud account has these permissions by default. If you use a Resource Access Management (RAM) user, contact the Alibaba Cloud account owner to go to the RAM console and grant the AliyunDataWorksFullAccess and AliyunBSSOrderAccess permissions to the RAM user. For more information, see Manage RAM user permissions.
Prepare the environment
This tutorial uses a standard mode workspace (with isolated development and production environments) for the demonstration. Follow these steps to prepare a DataWorks standard mode workspace and a DataWorks resource group with public network access. You also need to create and bind different MaxCompute projects for the development and production environments.
1. Activate services
This tutorial uses the China (Shanghai) region as an example. Prepare the environment based on the services you have activated in the China (Shanghai) region.
DataWorks service not activated
Follow these steps to activate a DataWorks edition and MaxCompute in the China (Shanghai) region. Then, prepare a Serverless resource group for DataWorks task scheduling and service execution.
Go to the service activation page.
Go to the Alibaba Cloud DataWorks official website and click Buy Now to enter the DataWorks service activation page.
Activate the services.
Configure the parameters as prompted on the page, and then click Confirm Order and Pay to complete the activation.
This case study uses the DataWorks Basic Edition (CNY 0/month), which covers basic data integration, data development, and scheduling capabilities. You can also choose other editions based on your business needs.
When you select a DataWorks Resource Group, you need to bind it to a connectable virtual private cloud (VPC). After binding, the DataWorks resource group can access Alibaba Cloud services within the specified VPC by default. You can customize the name of this resource group.
Confirm the resource.
NoteWhen you activate DataWorks for the first time, the system automatically creates a resource group. You need to confirm that the resource group was created successfully.
Go to the DataWorks resource group list. At the top of the page, switch the region to China (Shanghai) and confirm that the resource group has been created.
DataWorks Service is activated
If you have already activated any edition of DataWorks in the China (Shanghai) region, you need to manually create a Serverless resource group.
Go to the DataWorks resource group list. At the top of the page, switch the region to China (Shanghai) and click Create Resource Group.
Configure the parameters as prompted on the page, and then click Buy Now to purchase the resource group.
NoteYou must customize the Resource Group Name. You cannot create the resource group without a name.
If you do not have a VPC and a vSwitch, follow the prompts on the page to create them in the VPC console. For more information about VPCs and vSwitches, see What is a VPC?.
When you purchase a resource group for the first time, you need to create the AliyunServiceRoleForDataWorks service-linked role.
Confirm the resource.
Go to the DataWorks resource group list. At the top of the page, switch the region to China (Shanghai) and confirm that the resource group has been created.
2. Enable public network access for the resource group
DataWorks provides the raw data for this case study and its public network access address. To access this raw test data in DataWorks and ensure the case study runs smoothly, you must make sure your Serverless resource group has public network access.
The General-purpose Serverless resource group created when you activate DataWorks in Step 1 or created manually does not have public network access by default. You need to use an Internet NAT gateway to associate an Elastic IP Address (EIP) with the VPC bound to the resource group. This gives the resource group public network access. Follow the steps below.
Log on to the VPC - Internet NAT Gateway console. In the top menu bar, switch to the China (Shanghai) region and click Create Internet NAT Gateway. Configure the parameters as shown in the table below.
NoteKeep the default values for parameters not mentioned in the table.
Parameter
Value
Region
China (Shanghai).
Network and Zone
Select the VPC and vSwitch bound to the resource group.
You can go to the DataWorks resource group list page, switch to the China (Shanghai) region, find the created resource group, and click Network Settings in the Operation column. In the Data Scheduling & Data Integration area, view the Bound VPC and vSwitch. For more information about VPCs and vSwitches, see What is a VPC?.
NoteIf the current resource group is bound to multiple VPCs and vSwitches, make sure to configure and use the VPC and vSwitch from the first row of the list.
Network Type
Internet NAT gateway.
Elastic IP Address
Purchase New EIP.
Service-linked Role Creation
When creating a NAT Gateway for the first time, you need to create a service-linked role. Click Create Service-linked Role.
Click Buy Now and complete the payment to create the NAT Gateway instance.

After the NAT Gateway instance is purchased, click to return to the console and create an SNAT entry for the new instance.
NoteOnly after an SNAT entry is configured can the resource group using this VPC access the public network.
Click the Manage button in the operation column of the new instance to go to the management page of the target NAT Gateway instance. Switch to the SNAT Management tab.
Under the SNAT Entry List, click the Create SNAT Entry button to create an SNAT entry. Key configurations are as follows:
Parameter
Value
SNAT Entry Granularity
Select VPC Granularity to ensure that all resource groups within the NAT Gateway's VPC can access the public network through the configured EIP.
Select EIP Address
Configure the EIP address bound to the current NAT Gateway instance.
After configuring the SNAT entry parameters, click the Confirm button to create the SNAT entry.
Under the SNAT Entry List, when the Status of the newly created SNAT entry changes to Available, it means the VPC bound to the resource group has public network access.
3. Create a workspace
A workspace is the basic unit in DataWorks for task development, member permission management, and collaborative development. All development work in DataWorks is done within a workspace. Follow these steps to create a DataWorks standard mode workspace (with isolated development and production environments) for this case study.
Go to the workspace list page.
Go to the Workspace List. At the top of the page, switch the region to China (Shanghai), and then click Create Workspace.
Create the workspace. The following are the key parameters for this tutorial. Keep the default values for other parameters.
Workspace Name: Customize the workspace name. It cannot be changed after creation.
ImportantDataWorks workspace names must be unique across the entire network. You can customize the name or add a unique suffix to avoid naming conflicts.
Isolate Development and Production Environments: Enable this switch to specify the workspace mode as Standard Mode Workspace.
Use the new version of DataStudio: This tutorial works whether this is enabled or not. It indicates whether to use the new DataStudio features (recommended). If you do not see this option, it is enabled by default.
NoteThe new version of DataStudio provides capabilities for collaborative data development across multiple engines, visual workflow orchestration, and data catalog management. It supports interactive data exploration and analysis linked with AI using Notebooks. For more information about the new version of DataStudio, see DataStudio (New Version).
For a detailed comparison of core features and interface layouts between the new and old versions of DataStudio, see the DataStudio Upgrade Guide.
Workspace Template: Select All Capabilities.
Default Resource Group Configuration for DataWorks Workspace: Set this to the Serverless resource group created in Step 1.
Click Create Workspace.
NoteIf you selected Use the new version of DataStudio when creating the workspace, you will be guided to the Bind Computing Resource page. You can skip this for now by clicking Done or Close.
4. Bind MaxCompute as a computing resource
On the MaxCompute side: Create MaxCompute projects
This tutorial uses a standard mode workspace (with isolated development and production environments). You need to create two MaxCompute projects to serve as the compute engines for the development environment and the production environment. Follow these steps to create these two MaxCompute projects.
MaxCompute project names must be unique across the entire network. You can customize the project name or add a unique suffix to avoid naming conflicts.
Switch the region to China (Shanghai) to match the DataWorks region.
Log on to the MaxCompute console and select the region in the upper-left corner.
In the navigation pane on the left, choose , and click Create Project.
In the Create Project dialog box, configure the project information as prompted, and then click OK.
After the project is created, you can view the newly created MaxCompute project on the page in the navigation pane on the left of the MaxCompute console.
On the DataWorks side: Bind MaxCompute as a computing resource
In a standard mode workspace (with isolated development and production environments), you need to bind two MaxCompute projects as computing resources for the development and production environments. Follow these steps to bind the computing resources for both environments.
New Data Development Binding
Go to the DataWorks - Workspace List page, find the created workspace, and click Manage in the Operation column to enter the Management Center.
In the navigation pane on the left, click Computing Resource, click Bind Computing Resource, and select the MaxCompute type.
On the Bind MaxCompute Computing Resource page, fill in the following information in the Basic Information section (for more parameter details, see New version of DataStudio: Bind a MaxCompute computing resource):
Select the two created MaxCompute projects for the Development Environment and Production Environment respectively.
ImportantThe production and development environments must be bound to different MaxCompute projects to ensure isolation.
Default Access Identity: For the production environment, select Alibaba Cloud Account. The development environment only supports access using the Executor identity.
Computing Resource Instance Name: This identifies the computing resource. At runtime, the instance name is used to select the computing resource for the task.
In the Connection Configuration area, click Test Connectivity to test the network connectivity of the resource group. After it shows Connected, click Confirm to complete the binding.
Bind in the old version of DataStudio
Go to the DataWorks - Workspace List page, find the created workspace, and click the workspace name to enter the space details page.
In the navigation pane on the left, click Computing Resource. The page will redirect to the Data Development computing resource page. Click Create Computing Resource and select the MaxCompute type.
Bind the MaxCompute computing resource as prompted on the page.
Key parameter descriptions:
Data Source Name: You can customize this to represent the MaxCompute computing resource.
Owner Account: Set this parameter to Alibaba Cloud Account.
Region: Select the same region as the current DataWorks space, China (Shanghai).
MaxCompute Project Name: Select the two MaxCompute projects created in the China (Shanghai) region as the MaxCompute projects for the production and development environments, respectively.
ImportantThe production and development environments must be bound to different MaxCompute projects to ensure isolation.
Default Access Identity: The development environment defaults to Executor. For this tutorial, the production environment is set to Alibaba Cloud Account.
In the Connection Configuration area, click Test Connectivity to test the network connectivity of the resource group. After it shows Connected, click Create Computing Resource and Bind to Data Development to complete the binding.
Task development
This tutorial uses website user profile analysis as an example to show you how to implement specific business development and recurring scheduling with DataWorks and MaxCompute.
1. Flow design
The website user behavior analysis case uses the offline synchronization capability of the DataWorks Data Integration module to sync business data to MaxCompute. Then, it uses the MaxCompute SQL node in the DataWorks Data Development module to process the user profile data. The final processed result is written to the ads_user_info_1d table. The business data includes:
Basic user information stored in MySQL (ods_user_info_d). This is provided by the platform by default, so no activation is needed. You can access this data in your workspace by configuring its access information as a data source.
Website access log data stored in OSS (user_log.txt). This is provided by the platform by default, so no activation is needed. You can access this data in your workspace by configuring its access information as a data source.

2. Task development
Based on the Flow design, develop the workflow tasks in DataWorks. DataWorks provides the relevant code for this tutorial. You can quickly experience this case by importing it with one click. Later, you can also follow the User profile analysis (MaxCompute version) for a step-by-step hands-on experience.
Log on to the DataWorks console. In the navigation pane on the left, choose . Then, in the Category section, select Workflow.
Load the case study.
Click the Website User Profile Analysis card. On the case details page, click Load. Then, follow the on-screen instructions to load the case study.
Key parameter descriptions:
Workspace: Select the target workspace for importing the workflow case. Set this to the workspace created in Step 3.
Computing Resource Name: Select the computing resource that provides computing and storage services for this tutorial. Set this to the MaxCompute computing resource created and bound in Step 4.
Scheduling Resource Group and Integration Resource Group: Select the resource groups for task synchronization and scheduling. Set these to the resource group created in Step 1.
Loading Method: Select the processing policy for when the nodes and resources in the case are loaded into the workspace. Keep the default setting.
Publishing Rule: Select whether to directly enter the production scheduling system for daily automatic scheduling after the task is imported. Keep the default setting. Deselecting this means it will only be used for testing in data development and will not be automatically scheduled. You can manually publish it later.
Confirm the loading result.
On the Load Case page, click Confirm to start loading. You can view the Import Progress in the pop-up window. After all content is imported, you can click Go to View.
NoteClosing the Import Progress window will not affect the template import. You can go to the DataWorks - Workspace List page, click or in the operation column of the target workspace to view the imported template content in the data development module.
View the case study.
If you are using the new version of DataStudio, click
in the navigation pane on the left, then click the imported user_profile_analysiscase to open the corresponding workflow panel.You can double-click each node in the workflow to view the case background and the processing logic of each node.
NoteIf you are using the old version of DataStudio, under Data Development > Business Flow, double-click
experience_case_1_user_behavior_analysisto open the business flow canvas.You can double-click each node in the business flow on the canvas to view the case background and the processing logic of each node.
ImportantBefore the business flow is executed successfully for the first time, opening an offline sync task node (
) will report an error because the target MaxCompute table does not exist. You can first manually run the ancestor nodes (table_ddl_ods_raw_log_dandtable_ddl_ods_user_info_d) to create the target tables, and then view the offline sync details.Business data synchronization: The business data provided in this case study is simulated static test data. The offline sync task is responsible for syncing this test data to the specified date partition in MaxCompute daily.
Code parameter usage: In actual data synchronization and processing, you can use scheduling parameters for dynamic data handling. For example, by configuring the data timestamp parameter (format:
yyyymmdd, usually the previous day's date), you can automatically identify and process data for the corresponding data timestamp and write it to the specified date partition of the target table. For more information, see Scheduling parameters.In the new version of the DataStudio tutorial, each node's code uses
${workflow.var}to get the value of thevarparameter defined in the workflow. This allows for dynamic value assignment at runtime. Thevarparameter is assigned the value $[yyyymmdd-1] to get the data timestamp (yesterday).In the old version of the DataStudio tutorial, each node's code uses
${bizdate}to define a node-level parameter (this parameter name can be customized in actual development). The node then assigns a scheduling parameter to this parameter, enabling dynamic value assignment at runtime. The bizdate parameter is assigned the value$[yyyymmdd-1]to get the data timestamp (yesterday).
Dependency settings: For setting dependencies between task nodes, see Scheduling dependencies.
3. Run the task
After developing the task, you can run it to confirm that the code and flow meet expectations.
Run the user profile analysis flow: The imported case is a complete case. You can go to the workflow or business flow panel and click the Run button in the toolbar to run the workflow or business flow.
If you are using the new version of DataStudio, after clicking Run, the system will automatically read the
varparameter in the workflow. On the Fill in Runtime Parameters page, you need to assign a constant value to the parameter for the Current Run Value (for example, set the parameter to20250101).If you are using the old version of DataStudio, after clicking Run, you do not need to manually assign a value to the
bizdateparameter in the code. The system will automatically use the node parameter to assign a value to the bizdate parameter for this task execution.ImportantIf the run fails with the error "function or view getregion cannot be resolved", check if the
ip2region.jarresource and thegetregionfunction used in the processing flow have been published successfully. For the solution, see FAQ.
View the business flow execution process: Wait patiently until all task nodes have run successfully (all statuses are
) before proceeding.NoteTo view the running details of a node, you can click the node in the successfully executed workflow or business flow to view its operational log and execution information.
If you are using the new version of DataStudio, click Back at the top of the page to return to the workflow panel before proceeding.
Confirm the user profile data: Run the last task node individually to view the final user profile data.
On the workflow or business flow page, double-click the last node in the flow to enter the node details page. Select the following SQL statement, modify the
dtcondition, and click Run at the top of the page to query theads_user_info_1dtable and get the final user profile data.SELECT * FROM ads_user_info_1d where dt = '20250101' LIMIT 10;New version of DataStudio: The value for the
dtcondition in this query should match the Current Run Value you configured when running the workflow.Old version of DataStudio: The value for the
dtcondition in this query should match the data timestamp parsed in the business flow node.
Task O&M
1. Publish the task to the production environment
After the user profile analysis flow runs correctly in data development, you can publish the entire flow to the production scheduling system for periodic automatic execution.
If you selected the Auto Publish option when importing the case in the Task development step, no manual configuration is needed.
If you did not select Auto Publish when importing the case in the Task development step, manually publish the task to the production environment.
New version of DataStudio: In the workflow panel toolbar, click Publish to open the publish panel. Click Start Publishing to Production, follow the publishing guide, and click Confirm Publish to publish to the production environment.
Old version of DataStudio: In the business flow panel toolbar, click Commit, then click Publish, and follow the prompts to complete the publishing.
2. View production scheduling tasks
After a task is published, you can view all periodically scheduled tasks in the workspace on the page. Here, you can perform O&M operations on these tasks.
In the upper-left corner, choose to go to the Operation Center page.
In the navigation pane on the left of the Operation Center, choose . You can view all tasks in the scheduling system for the workspace. Typically, these tasks will be automatically scheduled according to their configurations. You can confirm the status of tasks in the production environment, including but not limited to the following:
Production task dependencies: Click the task name case_introduction_user_profile_analysis (new version of DataStudio) or user_behavior_analysis_case_description (old version of DataStudio) to enter the DAG panel. Right-click the first node and choose to quickly view the task's ancestor and descendant dependencies.
Production task details: Double-click any node in the DAG to quickly expand the node's Properties panel. Here, you can view the node's basic information, the node's Owner, Running Time, Operation Logs, and the Code used for scheduling and execution.
If you cannot find the task on this page, refer to Publish the task to the production environment to manually publish the task.
3. Backfill data from the same period last year
Data backfill can supplement data from a past period and write it to the corresponding time partition. This allows for processing data for a specified data timestamp and is mainly used for refreshing historical data.
This tutorial uses the data backfill feature to refresh data from the same period last year from the business system to MaxCompute. It then processes the historical user profile data in MaxCompute.
In the navigation pane on the left of the Operation Center, choose .
Data backfill in the new version of DataStudio:
In the Recurring Tasks list, find the zero load node case_introduction_user_profile_analysis.
Choose .
On the Backfill Data page, configure the parameters. Key parameter descriptions:
Include Current Task in Backfill: Set to Yes.
Select Descendant Nodes: Select all descendant nodes.
Data Timestamp: Set to the data timestamp for the same period last year.
Data backfill in the old version of DataStudio:
In the Recurring Tasks list, find the zero load node user_behavior_analysis_case_description.
Choose .
On the Backfill Data page, configure the parameters. Key parameter descriptions:
Include Current Task in Backfill: Set to Yes.
Select Descendant Nodes: Select all descendant nodes.
Data Timestamp: Set to the data timestamp for the same period last year.
Click Submit and Go to check if the data backfill task is successful.
DataWorks runs offline scheduling tasks as instances. After performing a data backfill operation on a task, you can view the instance details to understand the execution status of the backfill task.
You can click a task and then click View Log.
Confirm the MaxCompute table and partition where the data is written.
What to do next: View the recurring schedule status of the task
Tasks in the recurring task list run as instances. Automatic recurring scheduling generates recurring instances. The number of instances generated daily varies with the scheduling cycle. After the task is scheduled normally, you can choose in the navigation pane on the left to view the running status of individual instances.
An hourly task is defined to run between
00:00 and 23:59, scheduling once per hour. On the Recurring Instances page, 24 hourly instances will be generated each day. Each instance has its own instance ID as a unique identifier. All instances generated from the same task have the same task ID (node ID).If a recurring scheduling task runs abnormally, you can view the instance log to quickly locate the cause of the abnormality.
Query tasks
After the data backfill instance is complete, go to SQL Query. Use a SQL query to get the partition data from the same period last year, which was generated by the user profile analysis business flow through data backfill.
In the upper-left corner, choose .
Click SQL Query and create a query file under My Files.
Use the following SQL to query data from the same period last year in the production table
ads_user_info_1d.SELECT * FROM <production_project_name>.ads_user_info_1d where dt = '<actual_partition_written_to_production_table>';Before running, select the computing resource in the upper-right corner of the window.
NoteTo view the MaxCompute project bound to the DataWorks workspace production environment, see 4. Bind MaxCompute as a computing resource.
By default, RAM users do not have permission to access data in production project tables. If you get a permission error when querying production table data, you need to apply for permission in the Security Center. For more information, see MaxCompute data access control.
Release resources
To avoid incurring further charges, follow these steps to release the resources created in this tutorial.
Stop automatic recurring scheduling.
Go to the Operation Center page.
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 Operation Center.
Under , select all the recurring tasks you created, and then click Pause (Freeze) at the bottom.
(Optional) If you no longer need to run the scheduling tasks from this tutorial, you can choose .
Delete the Internet NAT gateway and release the EIP.
NoteInternet NAT gateways and EIPs incur configuration fees even when not in use (for billing details, see NAT Gateway billing and EIP billing). It is recommended to delete them when they are no longer needed. To run the business flow or execute scheduling for this tutorial again later, you can reconfigure the NAT Gateway and EIP for the VPC bound to the resource group. For more information, see Enable public network access for the resource group.
Log on to the VPC - Internet NAT Gateway console. In the top menu bar, switch to the China (Shanghai) region.
Find the created Internet NAT gateway. In the Operation column, choose . In the confirmation window, select Force Delete, and then click OK to delete.
In the navigation pane on the left, choose . Find the created EIP. In the Operation column, choose . In the confirmation window, click OK to release.
FAQ
Q: What should I do if the run fails with the error "function or view getregion cannot be resolved"?
A: You need to go to the Resource Management page to check and publish the ip2region.jar resource and the getregion function.
New version of DataStudio: To publish resources and functions, see Register a UDF.
NoteWhen publishing resources and functions, you can click Publish to open the publish panel. Click Start Publishing to Production, follow the publishing guide, and click Confirm Publish to publish to the production environment.
Old version of DataStudio: To commit resources and functions, see Create a function (getregion).
NoteWhen committing resources and functions, you can click the
button in the toolbar to complete the commit.