Use StreamSQL to write business logic, define data processing functions and operators, and save your script as a data processing task.
Procedure
- Log on to the Data Analysis console and select Task Development from the top navigation bar.
- On the Stream Data Task Development page, click Create Stream Data Task.
For Task Type, select SQL, enter a task name and description, and select whether to execute the task on the cloud or on the edge.
Table 1. Parameters Parameter Description Development Type Select SQL. Task Name The name of the SQL task. It must be 40 characters or less and can contain Chinese characters, English letters (case-sensitive), digits, underscores (_), hyphens (-), parentheses (), and spaces. Task Description A required description for the task. It must be 40 characters or less and can contain Chinese characters, English letters (case-sensitive), digits, underscores (_), hyphens (-), parentheses (), and spaces. Runtime environment Select whether to run the task in the cloud or on the edge. - Click OK.
After you create the SQL task, the system automatically redirects you to the Stream Data Task Development SQL Workbench.The workbench consists of the View management panel on the left, the SQL editor in the center, and a toolbar at the top for operations such as publishing and checking your SQL.Note
The images in this topic show the default (light) theme. IoT Data Analytics allows you to customize the workbench theme. To do this, click the settings icon
in the upper-right corner of the workbench and select Dark Theme. - In the View management panel on the left side of the SQL editor, click Add View to create a table for a product. This lets you reference the product's data in your SQL script. Use the format
pm_test.PM25, which follows thetable.attributesyntax.Enter a View name, select a product and device, and then click OK.
After the View is created, you can reference it in your SQL script.
For example, enter the SQL statementselect pm_test.PM25 from pm_test;to query data. - In the SQL editor, after you enter your SQL script, click the SQL check icon to check your SQL syntax.
- If the check passes, you can proceed to the next step.
- If the check fails, the system prompts you with the failure details.
Modify the SQL script based on the prompt. If you are unsure how to fix the script, go to the Stream Data Task Analysis page. Select a node programming task, click the task card to open its page, and then click the SQL preview icon in the upper-right corner to see a reference statement.
After you rewrite the SQL script based on the reference, run the check again until it passes, and then proceed to the next step.
- After you configure the task, click Publish in the upper-right corner.
When you publish the task, a real-time data processing job starts in the background. It performs real-time computations and continuously outputs the results to the destination data table of the specified data source.
Note If the task runs on the edge, you must also follow the instructions in Edge Stream Data Analysis to deploy the edge task.