Create Real-Time Tasks with Code

Last Updated on : 2024-06-20 06:50:31download

The topic describes how to create a real-time task with code.

Prerequisites

You have added at least one data source.

Procedure

  1. Log in to the Tuya Developer Platform.

  2. In the left-side navigation bar, click Data > Data Analysis > Project Manage.

  3. In the left-side navigation bar, click Data Processing > Real-time Task.

  4. Click New Task > Edit Code.
    Create Real-Time Tasks with Code

  5. Configure the data source.
    Create Real-Time Tasks with Code

  6. Configure the script.Create Real-Time Tasks with Code

    No. Area Description
    1 Data Table Data sources, most of which is log data currently.
    2 Dimension Table Dimension tables of data sources. You can press the Tab key to switch between the tables. The tables are the official dimension table (default), custom real-time table, and offline dimension table.
    3 Table Information Table field information of the selected data table or dimension table.
    4 Edit Code You can edit the Flink SQL statement here.
    5 Import Template The code template for your reference.
    6 Full Screen Enter the full screen mode.
  7. Configure the data transfer.

    Note: Only the real-time table is supported currently. Kafka and MQTT messages for billing users are coming soon.

    Create Real-Time Tasks with Code

    Term Description
    Data Source Transfer Type Select table storage or message queue. The message queue is coming soon.
    Data Storage Type Select a storage type. Only the summary table is supported currently.
    Data Storage Table Name You can define it.
    Table Alias For display.
    Data Storage Period Enter a specific number of days between 1 to 365.
    Table Field Definition The table field is parsed according to the above-mentioned Flink SQL. You can reset the field type and description and select whether to create an index. The two fields dt and gmtCreate are preset.
    Create an Index Creating an index will speed up pagination but consume additional storage. Select it as needed. You can select 10 fields at most.
    Unique Key Select one or more fields. It is a unique identifier of the multiple fields that you select
  8. After you finish configuring the data transfer, click Test below.
    The system will test the task, including message subscription of data sources, real-time processing, and writing data to a data table. If the task passes the test, it is created. If the test fails, you close the window and modify it. After modification, repeat the above procedure to test.

  9. After you create the task, go back to Real-time Task and click Start to complete run settings.
    Create Real-Time Tasks with Code