Step 1: Create an SQL analysis job

更新时间:
复制 MD 格式

Create an SQL analysis job and learn about the query object area, SQL statement editing area, and operation bar in the SQL analysis console.

Prerequisites

You have an Enterprise Edition instance of IoT Platform. For more information, see Purchase an Enterprise instance.

Background

Use the SQL analysis console to configure SQL analysis jobs. For more information, see SQL analysis overview.

Create an SQL analysis job

  1. In the IoT Platform console, go to the Overview page and click the ID or alias of the target Enterprise Edition instance.

  2. In the left navigation bar, select DataService Studio > Analytics Insight.

  3. On the Analytics Insight page, click New SQL Analysis.

  4. In the dialog box, enter the Data Development Name and Description for the SQL analysis job, and click Description OK.

    Important

    Data Development Name supports Chinese characters, letters, numbers, and underscores (32 characters maximum).

Open the SQL DataService Studio

  1. In the IoT Platform console, go to the Overview page and click the ID or alias of the target Enterprise Edition instance.

  2. In the left navigation bar, select DataService Studio > Analytics Insight.

  3. On the Analytics Insight page, find the target SQL analysis job, and in the Operation column, click Development Console.

    The SQL DataService Studio layout:

The console has the following areas.

Query object area (left pane)

Double-click a data table under any tab to use it as a query object.

Table type

Selectable data table

Description

Product storage table

Product attribute time-series table

Stores TSL property and event data reported by devices to the IoT Platform.

Product attribute snapshot table

Product event table

IoT Twin Engine time-series table

Stores TSL property data of twin nodes in the IoT Twin Engine twin space.

IoT Twin Engine snapshot table

Custom storage table

Transactional table

Stores custom-initialized data, including data parsed or generated by SQL analysis jobs, and data output to custom storage tables after task scheduling.

Partitioned table

Time-series table

Platform system table

Stores product, device, device group, tag, and location data.

SQL statement editing area (right pane)

Feature

Description

Run

Executes the SQL statement.

  • On success, view logs, results, and output structure in the Run Log, Results, and Output Structure tabs.

  • On failure, check error details in the Run Log tab and re-execute.

Stop

Stops the running SQL statement.

Verify SQL

Validates the SQL statement against basic specifications.

Format

Formats the SQL statement for readability. Example:

  • Before formatting:

    SELECT `description`, `gmt_create` AS `gmt_create_alias`, `gmt_modified` AS `gmt_modified_alias`, `group_id`, `group_type`, `name` FROM ${system.device_group} LIMIT 5
  • After formatting:

    SELECT `description`, `gmt_create` AS `gmt_create_alias`, `gmt_modified` AS `gmt_modified_alias`, `group_id`, `group_type`
    , `name`
    FROM ${system.device_group}
    LIMIT 5

Run Log

After executing the SQL statement:

  • Shown by default on failure.

  • Click to view on success.

Results

Shows query results by default on success.

Note

Displays up to 200 matching records.

Operation area (top bar)

Feature

Description

image.png

Click Publish And Execute to configure the execution policy and publish the SQL analysis job.

Configure these execution policies:

  • Result Storage Table: Specifies the custom storage table for query output.

  • Data Write Policy: Data write policy for scheduled jobs. Fixed to Primary Key Overwrite.

  • Primary Key: Displays the primary key field of the custom storage table.

  • Effective Date of Scheduling Policy: Sets the scheduling time range.

  • Scheduling Cycle: Sets the scheduling frequency.

Revoke

Click the Revoke icon to revoke a published SQL analysis job.

Save

Click the Save icon to save the current SQL analysis job configuration.

Shortcuts

Click the Shortcut Key icon to view keyboard shortcuts.

Windows shortcuts listed below. On Mac, use Command instead of Ctrl.

  • Save: Ctrl+S

  • Run: Ctrl+Enter

  • Format: Ctrl+F

  • Verify SQL: Ctrl+I

Help

Click the Help icon to access IoT DataService Studio documentation.

image.png

  • The SQL Templates provides ready-made templates for SQL analysis statements.