Step 3: Develop Data
In movie and TV show data analytics, operations teams regularly monitor popular movie rankings and user engagement. However, manually collecting statistics on massive amounts of raw data that is continuously updated is time-consuming and labor-intensive, and cannot ensure timeliness and accuracy. This step describes how to analyze the movie rating data to identify the top 10 rated movies and top 10 most-watched movies. It also describes how to configure periodic job scheduling and export execution results to tables every day for data analysis.
Script Development
Create the top_rating_movie DWS SQL script for storing top 10 rated movies.
Create the top_active_movie DWS SQL script for storing top 10 most-watched movies.
The method of finding out the 10 top-rated movies is as follows: Calculate the total score of each movie and the number of the users who participate in scoring the movies, filter out the movies that are scored by less than three users, and then return the movie names, average scores, and participant quantity.
- Log in to the DataArts Studio console.
For details, see Accessing the DataArts Studio Instance Console.
- On the DataArts Studio console, locate a workspace and click DataArts Factory.
- Create a DWS SQL script used to create data tables by entering DWS SQL statements in the editor. Figure 1 Creating a script
- In the displayed SQL editor, set key parameters.
Table 1 Key parameters Parameter
Description
Connection
DWS data connection created in Step 5
Database
Database created in Step 7
Figure 2 Key parameters
Enter the following SQL statements and click Execute to obtain the top 10 rated movies from the movies_item and ratings_item tables and save the result to the top_rating_movie table.SET SEARCH_PATH TO dgc; insert overwrite into top_rating_movie select a.movieTitle, b.ratings / b.rating_user_number as avg_rating, b.rating_user_number from movies_item a, ( select movieId, sum(rating) ratings, count(1) as rating_user_number from ratings_item group by movieId ) b where rating_user_number > 3 and a.movieId = b.movieId order by avg_rating desc limit 10Figure 3 Script (top_rating_movie)
- After debugging the script, click Save and Submit to submit the script and name it top_rating_movie. This script will be referenced later in Developing and Scheduling a Job.
- After the script is saved and executed successfully, create a DWS SQL script by referring to step 3 and run the following SQL statements to view the data in the top_rating_movie table. You can also download or dump the table data by referring to Figure 4.
SET SEARCH_PATH TO dgc; SELECT * FROM top_rating_movie
The method of finding out the 10 most frequently scored movies is as follows: Calculate the 10 most frequently scored movies whose average scores are higher than 3.5.
- Log in to the DataArts Studio console.
For details, see Accessing the DataArts Studio Instance Console.
- On the DataArts Studio console, locate a workspace and click DataArts Factory.
- Create a DWS SQL script used to create data tables by entering DWS SQL statements in the editor. Figure 5 Creating a script
- In the displayed SQL editor, set key parameters.
Table 2 Key parameters Parameter
Description
Connection
DWS data connection created in Step 5
Database
Database created in Step 7
Figure 6 Key parameters
Enter the following SQL statements and click Execute to obtain the top 10 most-watched movies from the movies_item and ratings_item tables and save the result to the top_active_movie table.SET SEARCH_PATH TO dgc; insert overwrite into top_active_movie select * from ( select a.movieTitle, b.ratingSum / b.rating_user_number as avg_rating, b.rating_user_number from movies_item a, ( select movieId, sum(rating) ratingSum, count(1) as rating_user_number from ratings_item group by movieId ) b where a.movieId = b.movieId ) t where t.avg_rating > 3.5 order by rating_user_number desc limit 10Figure 7 Script (top_active_movie)
- After debugging the script, click Save and Submit to submit the script and name it top_active_movie. This script will be referenced later in Developing and Scheduling a Job.
- After the script is saved and executed successfully, create a DWS SQL script by referring to step 3 and run the following SQL statements to view the data in the top_active_movie table. You can also download or dump the table data by referring to Figure 8.
SET SEARCH_PATH TO dgc; SELECT * FROM top_active_movie
Developing and Scheduling a Job
Assume that the movie and rating tables in the OBS bucket are changing in real time. To update top 10 movies every day, use the job orchestration and scheduling functions of DataArts Factory.
- Log in to the DataArts Studio console.
For details, see Accessing the DataArts Studio Instance Console.
- On the DataArts Studio console, locate a workspace and click DataArts Factory.
- Create a batch processing job named topmovie. Figure 9 Creating a job
Figure 10 Configuring the job
- Open the created job, drag two CDM Job nodes, three Dummy nodes, and two DWS SQL nodes to the canvas, select and drag
, and orchestrate the job shown in Figure 11. Table 3 Key nodes Key Node
Description
Begin (Dummy node)
Identifies the start and does not perform any operation.
movies_obs2dws (CDM Job node)
In node properties, select the CDM cluster in Step 2: Integrate Data and associate it with the CDM job movies_obs2dws.
ratings_obs2dws (CDM Job node)
In node properties, select the CDM cluster in Step 2: Integrate Data and associate it with the CDM job ratings_obs2dws.
Waiting (Dummy node)
Identifies the end of execution of the previous node and does not perform any operation.
top_rating_movie (DWS SQL node)
In node properties, associate this node with the DWS SQL script top_rating_movie you have created in Creating the top_rating_movie DWS SQL Script.
top_active_movie (DWS SQL node)
In node properties, associate this node with the DWS SQL script top_active_movie you have created in Creating the top_active_movie DWS SQL Script.
Finish (Dummy node)
Identifies the end and does not perform any operation.
- After configuring the job, click
to test it. - If the job runs properly, click Scheduling Setup in the right pane and configure the scheduling policy for the job. Figure 12 Configuring scheduling
Table 4 Scheduling parameters Parameter
Description
Schedule Type
Select Run periodically.
Scheduling Properties
Set the job scheduling time, for example, 01:00 every day from February 9, 2022 to February 28, 2022.
Dependency Properties
You can configure a dependency job for this job. You do not need to configure it in this example.
Cross-Cycle Dependency
The options include Independent on the previous schedule cycle and Self-dependent. Select Independent on the previous schedule cycle in this example.
- Click Save, Submit (
), and Execute (
). Then the job will be automatically executed every day so the 10 highest scored and most frequently scored movies are automatically saved to the top_active_movie and top_rating_movie tables, respectively. - If you want to check the job execution result, choose Monitoring > Monitor Instance in the left navigation pane. Figure 13 Viewing the job execution status
You can also configure notifications to be sent through SMS messages, emails, or console when a job encounters exceptions or fails.
Now you have learned the data integration and development process based on movie scores. In addition, you can analyze the ratings and browsing of different types of movies to provide valuable information for marketing decision-making, advertising, and user behavior prediction.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot


