Create a regular dimension logic table

Updated at:

A regular dimension logic table describes an entity and its attributes. For example, a regular dimension logic table for members might include their names, IDs, and email addresses. This topic describes how to create and configure a regular dimension logic table.

Limitations

  • If you do not have the data standard module, you cannot set the data standard field for the table.

  • If you do not have the asset security module, you cannot set the data security level and data category fields for the table.

  • If you do not have the asset quality module, you cannot perform unique and not-null checks on the primary key field.

Prerequisites

You have created a business entity. For more information, see Create and manage business entities.

Procedure

Step 1: Create a regular dimension logic table

  1. In the top navigation bar of the Dataphin homepage, choose Develop > Data Development.

  2. In the top navigation bar, select a Project. In Dev-Prod mode, you also need to select an Environment.

  3. In the left-side navigation pane, choose standard modeling > Dimension Logical Table.

  4. In the dimension logic table list on the right, click the image Create icon.

  5. In the Create Dimension Logical Table dialog box, configure the following parameters.

    Parameter

    Description

    Business object

    Select Standard Object.

    Table type

    When Business object is set to Standard Object, the table type is regular dimension logic table and cannot be modified.

    Data domain

    Defaults to the data domain associated with the project and cannot be modified.

    Subject domain

    Defaults to the subject domain of the business object and cannot be modified.

    Data timeliness

    Defines the data timeliness for the dimension logic table. Options for a regular dimension logic table include T+1 (daily table), T+h (hourly table), and T+m (minute-level table).

    Logical table name

    Enter a name for the logical table. The name must be 100 characters or less. After you select a business object, the system automatically populates the logical table name based on the following rule: {data_domain_name}.dim_{business_object_code}_{data_timeliness}.

    Important
    • The name can contain only letters, digits, and underscores (_), and must start with a letter. It is case-insensitive, and uppercase letters are automatically converted to lowercase.

    • The prefix label_ is reserved for the system. Do not start a name with label_.

    The value displayed for {data_timeliness} varies based on your selection:

    • df: T+1 timeliness for a daily full snapshot. It stores all historical data up to the current day.

    • hf: T+h timeliness for an hourly full snapshot. It stores all historical data up to the current hour.

    • mf: T+m timeliness for a minute-level full snapshot. Every 15 minutes, it stores all historical data up to the most recent 15-minute interval.

    Display name

    Follow these naming rules:

    • The name cannot exceed 128 characters.

    • All character types are supported.

    Description

    Enter a description (up to 1,000 characters).

  6. Click OK to create the regular dimension logic table.

Step 2: Configure the table fields

  1. On the table schema configuration page, define the table schema, including fields, data types, and field categories.

    image..png

    Note

    Click the image icon next to the logical table name to view its basic information.

    Section

    Description

    ① Field positioning

    Click to jump to the Basic Settings or data governance section in the field list.

    ② Search and filter

    You can search for fields by name.

    Click image..png to filter by Data type, Field category, Has associated dimension, Associated dimension, Field constraint, or Data security level.

    ③ Field list operations

    • Reorder fields: Before reordering fields, ensure that no downstream dependencies of this logical table use SELECT * to query it. This prevents data errors.

    • Import Fields: Import new fields into the table. You can Import from DDL Statement or Import from Table. For more information, see Import fields to a dimension logic table.

    • Add Field: Add a Data field or a Partition field. You can edit the field's Name, Description, Data type, Field category, Associated dimension, Field standard, Field constraint, Data category, Data security level, and Remarks as needed.

      Note

      The MaxCompute engine supports creating up to six levels of partition fields.

    ④ Field list

    The field list displays detailed information for each field, including No., Field name, Description, Data type, Field category, Associated dimension, Field standard, Field constraint, Data category, Data security level, and Remarks.

    • No.: The sequence number of the table field. It increments by 1 for each new field.

    • Field name: The name of the table field. You can enter a field name or a Chinese keyword to automatically match a predefined standard field name.

    • Description: A description of the field, limited to 512 characters.

    • Data type: Supported data types include STRING, BIGINT, DOUBLE, TIMESTAMP, DECIMAL, Text, Numeric, Date/Time, and Other.

    • Field category: Can be set to Primary key, Partition, or Attribute.

      Note
      • Only one primary key field is allowed.

      • Only fields of type STRING, VARCHAR, BIGINT, INT, TINYINT, or SMALLINT can be used as partition fields.

    • Associated dimension: For more information, see Add an associated dimension.

    • Field standard: Select a data standard for the field. To create a new standard, see Create and manage data standards.

    • Field constraint: Select a constraint for the field. Supports Unique and Not-null.

    • Data category: Select a data category for the field. To create a new data category, see Create a data category.

    • Data security level: After you select a data category, the system automatically determines the data security level.

    • Remarks: Enter remarks for the field, limited to 2048 characters.

    You can also Delete fields in the Actions column.

    Note
    • Field deletion is irreversible.

    • The primary key and system partition fields of a dimension logic table cannot be deleted.

    ⑤ Batch operations

    You can select multiple fields to perform the following batch operations.

    • Delete: Click the image icon to delete the selected data fields.

    • Data type: Click the image icon to change the data type for the selected fields.

    • Field category: Click the image icon to change the field category for the selected fields.

    • Stem-based naming: Click the image icon. The system tokenizes the content in the Description field, matches it with existing stems, and recommends field names. In the Stem-based naming dialog box, you can replace the names of the selected fields with the modified values.

      Note
      • If none of the recommended field names meet your requirements, you can edit them in the Modified field name input box.

      • Click Reset to revert the Modified field name to the system's matched stem.

    • Field standard: Click the image icon. The system recommends a field standard based on the field name. In the Field standard dialog box, you can apply the recommended standard to the field.

    • Field constraint: Click the image icon to set field constraints in bulk.

      Important

      Field constraints cannot be set for sub-dimension logical tables.

  2. Click Save and Next.

Import fields to a dimension logic table

  • Import from Table

    1. On the configuration page of the dimension logic table, click Import from Table.

    2. In the Import from Table dialog box, select a Source table, and then select the fields you want to add.

      Parameter

      Description

      Source table

      You can select any physical table (excluding those auto-generated by Dataphin), logical table, or view (non-parameterized) within the current tenant for which you have read permissions.

      To obtain read permissions for a physical table, see Apply for, renew, and return table permissions.

      Field list

      Select the fields you want to add.

      Note

      You can switch between source tables to select fields from multiple tables.

      Selected fields

      The added fields appear in the selected fields list. You can Delete fields from this list.

    3. Click Add to import the fields from the physical table into the dimension logic table.

      After the fields are added to the New Fields area, you can edit their names, data types, field categories, and associated dimensions as needed.

  • Import from DDL Statement

    1. On the configuration page of the dimension logic table, click Import from DDL Statement.

    2. In the Import from DDL Statement dialog box, enter the DDL statement and click Parse SQL.

    3. Select the required fields from the field list and click Add to create new fields in the dimension logic table.

Add an associated dimension

  1. On the configuration page of the dimension logic table, click the gagag icon in the Associated dimension column to open the Edit Model Relation dialog box.

  2. In the Edit Model Relation dialog box, configure the parameters.

    Section

    Parameter

    Description

    Null replacement value

    If the main table (the current dimension logic table) fails to join with the associated dimension logic table, Dataphin uses -110 as the default value for the associated fields.

    Dimension logical table

    Associated entity and Dimension logical table

    Select the Associated entity and Dimension logical table that you have created.

    Edit association logic

    Association logic

    Displays the field to be associated and the primary key of the associated dimension logic table by default. This cannot be modified.

    Dimension table version policy

    Defines the partition relationship between the main table (the current dimension logic table) and the associated dimension logic table. By default, both tables share the same scheduling cycle.

    • Use dimension of the same period (main table and dimension table use partitions of the same period): The main table and the associated dimension logic table use the same time partition for calculation.

      For example, if the business date is 20220101, and you need to query the ds=20220101 partition of the main table while the associated dimension logic table also uses the 20220101 partition, select this option.

    • Use the latest dimension table (dimension table uses the latest partition): Data calculation uses the latest partition of the associated dimension logic table.

      For example, a product category changes frequently. An item was in the 'Mobile Phones' category 10 days ago but is in the 'Appliances' category today. If you need to reprocess the data from 10 days ago using the 'Appliances' category, you must select Use the latest dimension table (dimension table uses the latest partition).

    Join failure policy

    This policy defines how to handle records from the source table (left table) that do not have a match in the dimension logic table (right table). You can choose to Retain original unassociated data or Replace unassociated data with default value.

    • Retain original unassociated data: Retains the original data from the left table when creating a derived metric.

    • Replace unassociated data with default value: If a field in the main table cannot be joined with the dimension logic table, it is replaced with the default value of -110.

    Edit dimension role

    Role English name and Role name

    A dimension role acts as a dimension alias. This allows a dimension to be referenced multiple times with different names in role-playing scenarios. You must define a Role English name and a Role name.

    • The Role English name defaults to the prefix dim. The custom part must adhere to the following rules:

      • Contains only letters, digits, or underscores (_).

      • Cannot exceed 64 characters.

    • The Role name must adhere to the following rules:

      • Contains only Chinese characters, digits, letters, underscores (_), or hyphens (-).

      • Cannot exceed 64 characters.

  3. Click OK.

Step 3: Configure the calculation logic

  1. On the calculation logic configuration page, configure the mapping between the source data and the primary key of the dimension logic table.

  2. Click Source Configuration to open the Source Configuration dialog box, then click + Add Source Object to configure the source parameters.

    Note

    Do not add extra filters for event time in the filter conditions or in Custom SQL.

    Parameter

    Description

    Source type

    Supported source types are Physical table, Custom SQL, and Logical table.

    Source table type descriptions:

    • Source table with a primary key: A logical table with a primary key can have multiple sources. The first is always the primary source, which determines the total number of rows in the logical table.

    • Source table without a primary key: A logical table without a primary key can have only one source. If the source involves multiple tables, use Custom SQL to pre-join them.

      Note

      To configure multiple source objects, click Add Source Object.

    Source object

    • Select Physical table: You can select any physical table (excluding those auto-generated by Dataphin) or physical view (non-parameterized) within the current tenant for which you have read permissions.

      To obtain read permissions for a physical table, see Apply for, renew, and return table permissions.

    • Select Custom SQL: Click the image icon and enter your content in the editor. Example:

      select id, name
      from project_name_dev.table_name1 t1
      join
      project_name2_dev.table_name2 t2
      on t1.id = t2.id
    • Select Logical table: You can select any logical table within the current tenant for which you have read permissions.

      To obtain read permissions for a physical table, see Apply for, renew, and return table permissions.

      Important

      Using a logical table as a data source for another logical table increases the complexity of the calculation logic and operational overhead.

    Object alias

    Define a custom alias for the source table, for example, t1 or t2.

    Object description

    Enter a description for the object, up to 1,000 characters.

    Filter

    Define a filter condition for the Custom SQL.

    Click the image icon and enter your content in the editor. Example:

    ds=${bizdate} and condition1=value1

    Associated field

    The field in the source object that corresponds to the logical table's primary key and can be used for an equi-join.

    Delete

    The primary source cannot be deleted.

    For a logical table without a primary key, deleting the source clears the calculation logic for its fields.

  3. Click OK to finish configuring the source.

  4. After configuring the source, drag the Source Fields into the calculation logic area. You can also click Map fields with the same name to automatically map source fields to logical table fields with the same name.

    Click the image icon to edit the calculation logic expression in the editor. Aggregation functions such as SUM, COUNT, and MIN are not supported. Examples:

    • Example 1: substr(t1.column2, 3, 10)

    • Example 2: case when t1.column2 != '1' then 'Y' else 'N' end

    • Example 3: t1.column2 + t2.column1

  5. After configuring the calculation logic, click the image..png icon at the bottom to validate the expression.

    Click Preview SQL to view the SQL for the calculation logic.

  6. Click Save and Next.

Step 4: Configure constraints

  1. The system creates quality rules in the quality module based on the field constraints you define. You can set the Rule severity for the fields, which can be a Strong rule or a Weak rule. For more information, see Data table quality rules.

    Note

    Rule severity for logical table field constraints can only be configured here and cannot be edited in the quality module.

  2. Click Save and Next.

Step 5: Configure scheduling

  1. On the Scheduling & parameters page, configure the Data latency, Scheduling properties, Upstream dependencies, Scheduling parameters, and Runtime configuration for the dimension logic table.

    Parameter

    Description

    Data latency

    If you enable data latency, the system automatically reruns all data for this logical table within the Maximum Latency Days period. For details, see Configure data latency for a logical table.

    Scheduling properties

    Defines how the dimension logic table is scheduled in the production environment. You can configure its scheduling type, cycle, logic, and execution. For details, see Configure scheduling properties for a logical table.

    Upstream dependencies

    Dataphin uses scheduling dependencies to run nodes in the correct order, ensuring timely and effective data output. For details, see Configure upstream dependencies for a logical table.

    Scheduling parameters

    Parameter configuration assigns values to code variables. These variables are automatically replaced with the assigned values during scheduling. On the parameter configuration page, you can Ignore a parameter or Convert to global variable. For details, see Logical table runtime parameter configuration.

    Runtime configuration

    You can configure a task-level timeout and a retry policy for this dimension logic table. This prevents resource waste from long-running tasks and improves the reliability of task execution. For details, see Logical table runtime configuration.

    Resource configuration

    You can configure a scheduling resource group for the current logical table task. The task will use the resource quota of this group when it is scheduled. For configuration details, see Logical table resource configuration.

  2. Click Save and Submit.

Step 6: Save and submit the logical table

  1. After configuring the regular dimension logic table, click Save and Submit.

    The system validates the configurations for table schema, calculation logic, scheduling dependencies, and runtime parameters. If any checks fail, review and correct the configuration based on the Check Result.

  2. Once all checks pass, enter submission remarks and click OK and Submit.

    During submission, Dataphin performs lineage parsing and submission checks. For more information, see Submission notes for standard modeling tasks.

Next steps

If your project is in Dev-Prod mode, you need to publish the logical table to the production environment. For more information, see Manage publishing tasks.

After the logical table is published to the production environment, go to the Operations Center to view and maintain the logical table task. For more information, see Operations Center.