All Products
Search
Document Center

:Data registration and field configuration

Last Updated:Apr 01, 2026

To generate experiment reports in PAI-Rec, you need a MaxCompute source table that records per-user, per-experiment behavioral events. Register this table in the PAI-Rec console, then configure which columns serve as dimension fields and which as compute fields. PAI-Rec dynamically assembles SQL, runs statistics against your source table, and writes results to a Hologres database for display on the Performance Reports page.

How it works

image.png

PAI-Rec integrates the SDK of the configuration center, which supplies experiment assignments at serving time. Each recommendation response includes an experiment ID (exp_id) and a request ID (reqid).

When a user interacts with your app, the front-end event tracking task writes behavioral logs to MaxCompute. A scheduled SQL job aggregates those logs into an experiment report source table — grouping records by user_id, exp_id, and the date partition (dt) — and optionally by dimension fields such as country or OS. After you configure metrics in the configuration center, PAI-Rec runs SQL against the source table and stores the aggregated results in Hologres.

Prerequisites

Before you begin, make sure you have:

  • An activated MaxCompute instance (previously known as ODPS)

  • A MaxCompute project bound to your AIRec instance

  • A MaxCompute experiment report source table created and populated with behavioral log data

Prepare the source table

Experiment report source tables use user_id, exp_id, and a date partition as the composite primary key. Each row represents the aggregate behavior of one user in one experiment on a given day (or hour). You can create an offline table (aggregated daily or hourly) or a real-time table (aggregated hourly, partitioned by both date and hour).

Offline metrics and real-time metrics cannot share a result table. If your source table is generated offline, you can only create offline metrics against it. If it is generated in real time, you can create both offline and real-time metrics from the same source.

Offline source table

An offline source table is partitioned by date (dt) and optionally by hour (hh). Use this table type when your behavioral log pipeline runs on a daily or hourly batch schedule.

SQL to create the table:

CREATE TABLE IF NOT EXISTS experiment_report (
    user_id            STRING COMMENT 'User ID',
    exp_id             STRING COMMENT 'Experiment ID',
    exposure_count     BIGINT COMMENT 'Exposure count',
    click_count        BIGINT COMMENT 'Click count',
    like_comment_collect_count BIGINT COMMENT 'Like count'
)
PARTITIONED BY (dt STRING COMMENT 'Date')
STORED AS ALIORC;

SQL to populate the table (example):

INSERT OVERWRITE TABLE experiment_report PARTITION (dt = '${bdp.system.bizdate}')
SELECT
    user_id,
    exp_id,
    SUM(IF(event == 'expose', 1, 0)),
    SUM(IF(event == 'click', 1, 0)),
    SUM(IF(event IN ('like', 'comment', 'collect'), 1, 0))
FROM rec_sln_demo_behavior_table_v1
WHERE ds = '${bdp.system.bizdate}'
GROUP BY user_id, exp_id;

Field reference:

FieldRequiredTypeFormat / rules
user_idYesSTRINGUser ID, device ID, or International Mobile Equipment Identity (IMEI)
exp_idYesSTRINGExperiment ID returned by the A/B test and logged by the event tracking task. Example: ER1_L1#EG1#E1_L2#EG2#E2
Dimension fieldNoSTRINGUp to 2 dimension fields (e.g., province, city). A third field creates too many combinations and significantly slows calculation.
Compute fieldYesBIGINTNumeric values only — impression count, click count, view duration, and so on.
dtYesSTRINGDate partition in yyyyMMdd format
hhNo (required for hourly tables)STRINGHour partition in 24-hour format (0023)
mmNoSTRINGMinute partition (0059)

Required fields by schedule:

ScheduleRequired fields
Dailyuser_id, exp_id, dt
Hourlyuser_id, exp_id, dt, hh

Real-time source table

A real-time source table is partitioned by both date (dt) and hour (hh). Use this table type when you need hourly experiment reports.

SQL to create the table:

CREATE TABLE IF NOT EXISTS experiment_report_real (
    user_id            STRING COMMENT 'User ID',
    exp_id             STRING COMMENT 'Experiment ID',
    exposure_count     BIGINT COMMENT 'Exposure count',
    click_count        BIGINT COMMENT 'Click count',
    like_comment_collect_count BIGINT COMMENT 'Like count'
)
PARTITIONED BY (
    dt  STRING,
    hh  STRING
)
STORED AS ALIORC;

SQL to populate the table (example):

INSERT OVERWRITE TABLE experiment_report_real
    PARTITION (dt = '${bdp.system.bizdate}', hh = '${hour}')
SELECT
    user_id,
    exp_id,
    SUM(IF(event == 'expose', 1, 0)),
    SUM(IF(event == 'click', 1, 0)),
    SUM(IF(event IN ('like', 'comment', 'collect'), 1, 0))
FROM rec_sln_demo_behavior_table_v1
WHERE ds = '${bdp.system.bizdate}'
  AND hh = hour(now()) - 1
GROUP BY user_id, exp_id;

Field reference:

FieldRequiredTypeFormat / rules
user_idYesSTRINGUser ID, device ID, or IMEI
exp_idYesSTRINGExperiment ID returned by the A/B test and logged by the instrumentation task
Dimension fieldNoSTRINGUsed to filter metrics by a specific attribute, such as OS. The definition must match the corresponding dimension field in the result table.
Compute fieldYesBIGINTNumeric values only — impression count, click count, and so on.
dtYesSTRINGDate partition in yyyyMMdd format
hhYesSTRINGHour partition in 24-hour format (0023)
mmNoSTRINGMinute partition (0059)

Register a MaxCompute table

After creating your source table, register it in the PAI-Rec console so PAI-Rec can reference it when calculating metrics.

Tip: To write metric results, use the default Hologres table. It does not consume resources — PAI-Rec creates and manages the table automatically. To use a Hologres table you created yourself, select it during metric configuration.
  1. In the PAI-Rec console, go to Metric Management > Data Registration.

  2. Click Create Data Table.

  3. In the panel that appears:

    • Select the MaxCompute project.

    • Select the MaxCompute data table.

    • Enter a name for the table.

  4. Click Import.

image.png
Important

If you modify the fields in a registered table, re-import the table immediately. Otherwise, PAI-Rec may not recognize the updated fields.

Configure fields

After registering the table, configure which columns are dimension fields and which are compute fields.

  1. On the Data Registration page, find the table in the list.

  2. Click View Fields in the Actions column.

image

The user_id, exp_id, and dt fields are required and are pre-configured. These three fields form the composite primary key: they identify the total behavior (impressions, clicks, likes) of a specific user (user_id) in a specific experiment (exp_id) on a specific day (dt).

Dimension fields

Dimension fields let you slice experiment report data by an attribute. For example:

  • Set city as a dimension field to compare experiment results across cities.

  • Set both city and gender as dimension fields to compare results by the combination of city and gender.

Add up to 2 dimension fields per table. A third dimension field creates too many group combinations and significantly slows down metric calculation.

Common dimension fields include:

  • User attributes: gender, os (iOS, Android), country

  • Recommendation attributes: recall_id (to analyze performance by recall source — requires PAI-Rec engine backend log configuration; see Other configurations for pairec_debug_log)