Updated on 2024-11-29 GMT+08:00

Adding a Batch Variable

Scenario

Batch variables are calculated by your offline analysis platform, and the platform data is generally stored in Hadoop. You can specify a batch variable table for dimension mapping, where a dimension corresponds to a batch variable table.

A dimension can have multiple batch variables.

Procedure

  1. Create the batch variable table.

    1. Log in to the RTDservice web UI as a service user and select a tenant.
    2. Choose Business Management > Database Tools > Database Operator.
    3. Set Operation to DDL and run the following statement to create the batch variable table T_RTD_BATCH_VARS_PARENT_1:
      CREATE TABLE T_RTD_BATCH_VARS_PARENT_1 (
      CUR_VER_FLAG tinyint DEFAULT '0' NOT NULL,
      KEY varchar(20 BYTES) NOT NULL,
      VALUE varchar(1048576 BYTES) NOT NULL,
      CONSTRAINT PK_T_RTD_BATCH_VARS_PARENT_1 PRIMARY KEY (KEY));

      The structure of the batch variable table is as follows:

      Figure 1 Table structure
      Table 1 Fields in the batch variable table

      Field

      Description

      CUR_VER_FLAG

      Data flag, indicating whether the data is available. The value 0 indicates that the data is available, and the value 1 indicates that the data is unavailable.

      KEY

      Dimension primary key.

      VALUE

      The value contains key-value pairs in JSON format.

      NOTE:
      • key indicates a batch variable name and must be in lowercase.
      • value indicates the value of a batch variable.
      • Multiple key-value pairs can be configured.
      • The system processes batch variables on the offline Hadoop platform, which decouples online data processing from offline data analysis and computing. This ensures real-time data processing and provides platform support for high-performance batch computing.
      • Batch variables are not supported in filtering rules.
    4. Set Operation to DML and run the following statement to insert data:
      For example, if a record whose batch variable name is bv_wq is inserted into the batch variable table T_RTD_BATCH_VARS_PARENT_1, the value of the batch variable is 2000 when 3 is entered.
      insert into T_RTD_BATCH_VARS_PARENT_1(key ,value)  values('3','{"bv_wq":"2000"}');

  2. Log in to the RTDservice web UI as a service user and select a tenant.
  3. Choose Business Management > Variable and Rule Configuration > Batch Variables.
  4. On the displayed page, click Add. Select a dimension from Dimension Name, and set the Name, Type, Default Value, and Description of the batch variable.

    • When adding a batch variable, ensure that the batch variable name is the same as the internal keys contained in VALUE in the batch variable table created in 1. Otherwise, the batch variable calculation on the platform fails and an error message is generated.
    • The prefix of the batch variable name must be bv_.
    • The variable name is case insensitive and must start with a letter or underscore (_). A name can contain a maximum of 30 characters, including [A-Z], [a-z], [0-9] and _.
    Figure 2 Creating a batch variable

  5. Click OK. The batch variable is created.
  6. (Optional) On the Batch Variables page, if the variable is Ready, select the variable and choose More > Online or Offline to bring the batch variable online or take it offline.