Data registration
Data registration requires you to activate MaxCompute, bind a project, and register a MaxCompute table. This registered table serves as an intermediate table for performance statistics, called the experiment report source table. It uses a composite primary key of user_id, exp_id, and dimension fields to aggregate statistics. Each row represents metrics such as exposures and clicks for a specific user in a specific experiment. You can add dimensions such as country to build a more granular intermediate statistics table keyed on user_id, country, and exp_id. All basic and derived metrics depend on this intermediate table. The overall experiment architecture is as follows:
The PAI-Rec engine is a recommendation service that integrates an SDK from the configuration center to retrieve experiment information. The response includes the experiment ID (exp_id) and a request ID (reqid).
When a user interacts with your application, front-end event tracking collects behavior logs and sends them to MaxCompute. An SQL task processes these logs to generate the experiment report source table. After you configure metrics in the configuration center, the system dynamically assembles SQL queries to compute statistics from this source table. The results are stored in Hologres, and you can view them on the experiment report page.
I. Offline experiment reports
Offline experiment report source table code
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, comment, and collect count'
)
PARTITIONED by (dt STRING COMMENT 'Date')
STORED AS ALIORC;
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_idOffline experiment report source table schema
Parameter | Description | Required | Notes |
| User ID | Yes | A unique user identifier, such as a UID, |
| Experiment ID | Yes | The experiment ID returned by the A/B testing service and logged via event tracking. If you use your own recommendation service, you can set a custom identifier. Example: |
Dimension field | A field used for more granular statistical reporting. | No | Use this field to group and display corresponding metrics. For example, add a You can specify up to two dimension fields, such as A common dimension field is |
Compute field | You can have multiple compute fields. Example: Example: | Yes | A numeric field that you provide, such as exposure count, click count, or view duration. |
| Date partition | Yes | Format: |
| Hour partition | No | 24-hour format: |
| Minute partition | No |
|
You can generate the source table daily for offline reports or hourly for near-real-time reports, depending on your business needs. For example, use DataWorks to schedule a job that runs every hour to process logs from the previous hour. For offline generation, user_id, exp_id, and dt are required. For hourly reports, user_id, exp_id, dt, and hh are required; the mm partition is optional.
A real-time data source supports both offline and real-time metrics. An offline data source supports only offline metrics.
Dimension fields are optional but enable dimensional analysis of your metrics. Common dimension fields include gender and os (operating system, such as iOS or Android), which let you view report data segmented by gender or operating system.
Offline significance report source table code
CREATE TABLE IF NOT EXISTS experiment_report_v3 (
user_id STRING COMMENT 'User ID',
exp_id STRING COMMENT 'Experiment ID',
item_id STRING COMMENT 'Item ID',
request_id STRING COMMENT 'Request ID',
click_uv BIGINT COMMENT 'Click UV',
expr_pv BIGINT COMMENT 'Exposure PV'
)
PARTITIONED by (dt STRING COMMENT 'Date')
STORED AS ALIORC;
INSERT OVERWRITE TABLE experiment_report_v3 PARTITION (dt = '${bdp.system.bizdate}')
SELECT
user_id,
exp_id,
item_id,
request_id,
MAX(IF(event = 'click', 1, 0)) AS click_uv,
SUM(IF(event = 'expr', 1, 0)) AS expr_pv
FROM rec_sln_demo_behavior_table_v1
WHERE ds = '${bdp.system.bizdate}'
GROUP BY
user_id,
exp_id,
item_id,
request_idOffline significance report source table schema
Parameter | Description | Required | Notes |
| User ID | Yes | A unique user identifier, such as a UID, |
| Experiment ID | Yes | The experiment ID returned by the A/B testing service and logged via event tracking. If you use your own recommendation service, you can set a custom identifier. Example: |
| Item ID | Yes | |
| Request ID | Yes | |
Dimension field | A field used for more granular statistical reporting. | No | Use this field to group and display corresponding metrics. For example, add a You can specify up to two dimension fields, such as A common dimension field is |
Compute field | You can have multiple compute fields. Example: Example: | Yes | A numeric field that you provide, such as exposure count or click count. |
| Date partition | Yes | Format: |
II. Real-time experiment reports
Real-time experiment report source table code
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, comment, and collect count'
)
PARTITIONED by (
dt string
,hh string
)
STORED AS ALIORC;
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;Real-time experiment report source table schema
Parameter | Description | Required | Notes |
| User ID | Yes | A unique user identifier, such as a UID, |
| Experiment ID | Yes | The experiment ID returned by the A/B testing service and logged via event tracking. If you use your own recommendation service, you can set a custom identifier. Example: |
Dimension field | Example: | No | Used to filter report data by this dimension. |
Compute field | You can have multiple compute fields. Example: | Yes | A numeric field that you provide, such as exposure count, click count, or view duration. |
| Date partition | Yes | Format: |
| Hour partition | Yes | 24-hour format: |
| Minute partition | No |
|
The fields in the result table are mostly fixed; only dimension fields are variable. The definition of a dimension field in the result table must match its definition in the source table.
Offline metrics and real-time metrics cannot use the same result table. A result table for offline metrics requires only the dt date partition, whereas a real-time table must include at least the hh hour partition.
After you create the experiment report source table, go to Metric Management > Data Registration in the console to add the new MaxCompute data table.
We recommend using the default Hologres table to store metric calculation results. This option does not consume your own resources because the system automatically creates and manages the table. Alternatively, you can use your own Hologres instance and table.
III. Register a MaxCompute table
Click Create Data Table, select your bound MaxCompute project, choose the MaxCompute data table, provide a custom name, and then click Start Import to import the table data.
If the schema of a registered data table changes, you must re-import it promptly. Otherwise, the system may not recognize the field changes.
Field configuration
After registration, the data table appears in the list. Click View Fields to review and edit the fields. The user_id, exp_id, and dt fields are required. Together, these fields track behavior totals such as exposures, clicks, and likes for a specific user (user_id) in a specific experiment (exp_id) on a given day (dt). Custom metrics are defined and calculated based on this table.
Dimension fields
You can add one or two dimension fields to the table. For example, if you set city as a dimension, the experiment report shows a comparison of experiment results for each city. If you set both city and gender as dimension fields, the report shows results grouped by the combination of these two fields.