Create a fact logical table

Updated at:

You create a fact logical table by adding multiple attributes to a business activity. It contains fields for a primary key, measures, and fact attributes. The primary key defines the logic for retrieving data from source tables. Measures are numeric fields that represent quantities, amounts, or degrees. This topic shows you how to create and configure a fact logical table.

Limitations

  • Without the Data Standard module, you cannot set the data standard for fields in the table.

  • Without the Asset Security module, you cannot set the data security level or data category for fields in the table.

  • Without the Asset Quality module, you cannot perform unique and non-null validation for primary key fields.

Prerequisites

You must have created a business activity object. For more information, see Create and manage business entities.

Procedure

Step 1: Create the fact logical table

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

  2. In the top navigation bar, select a Project. If you are in Dev-Prod mode, you must also select an Environment.

  3. In the left-side navigation pane, choose Standard Modeling > Fact Logical Table.

  4. In the fact logical table list on the right, click the image New icon.

  5. On the Create Fact Logical Table page, configure the following parameters.

    Parameter

    Description

    Business activity

    Select the business activity for which you want to create a fact logical table. Business activities are categorized as Business event, Business snapshot, or Business process.

    Table type

    The logical table type is determined by the business activity type.

    • If you select Business event for Business activity, the Table type is Event fact logical table.

    • If you select Business snapshot for Business activity, the Table type is Snapshot fact logical table.

    • If you select Business process for Business activity, the Table type is Process fact logical table.

    Data domain

    This parameter defaults to the data domain of the business activity and cannot be changed.

    Subject area

    This parameter defaults to the subject area of the business activity and cannot be changed.

    Data timeliness

    Specifies the scheduling type for the fact logical table task in the production environment. You can select Offline T+1 (daily task), Offline T+h (hourly task), or Offline T+m (minute-level task).

    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 name using the format {data_domain_name}.fct_{business_object_code}_{data_timeliness_suffix}.

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

    • label_ is a system-reserved prefix, and you cannot start labels with label_.

    The {data_timeliness_suffix} varies based on the data timeliness setting:

    • di: Daily incremental (T+1). Stores the incremental data for the current day.

    • hi: Hourly incremental (T+h). Stores the incremental data for the current hour.

    • thi: Hourly cumulative incremental (T+h). Stores the incremental data from 00:00 to the current hour.

    • mi: Minute-level incremental (T+m). Stores the incremental data of the last 15 minutes in a new partition every 15 minutes.

    • tmi: Minute-level cumulative incremental (T+m). Stores the incremental data from 00:00 to the current minute in a new partition every 15 minutes.

    • df/da: Daily full (T+1). Stores the full data up to the current day.

    • hf: Hourly full (T+h). Stores the full data up to the current hour.

    • mf: Minute-level full (T+m). Stores the full data up to the last 15 minutes in a new partition every 15 minutes.

    Display name

    The display name must follow these rules:

    • Can contain Chinese characters, letters, digits, underscores (_), and hyphens (-).

    • Must be 64 characters or less.

    Description

    Enter a brief description of the fact logical table, up to 1,000 characters.

  6. Click OK.

Step 2: Configure the table structure

  1. On the Table Structure page, configure the parameters.

    image

    Area

    Description

    ① Field navigation

    Click to navigate to the Basic Configuration or data governance section of the field list.

    ① Search and filter area

    You can search for fields by name.

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

    ② List operations

    • Adjust Field Order: Before you adjust the field order, make sure that no downstream applications use select * to query this logical table, as this can cause data errors.

    • Import fields: Import new fields into the table. You can import from a DDL statement or import from table. For more information, see Import fields into a fact logical table.

    • Add field: Add a data field or a partition field. You can edit the Name, Description, Data type, Field category, Associated dimension, Field standard, Field constraint, data category, data security level, and Remarks for the field.

      Note

      For the MaxCompute engine, you can create 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 field. The number increments by one for each new field.

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

    • Description: The description of the field, up to 512 characters.

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

    • Field category: You can set the category 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 standard for the field. To create a standard, see Create and manage data standards.

    • Field constraint: Select a constraint for the field. Supported constraints are Unique and Non-null.

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

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

    • Remarks: Enter remarks for the field, up to 2,048 characters.

    You can also delete a field in the Actions column.

    Note

    Field deletion cannot be undone.

    ④ 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.

    • Radical-based Naming: Click the image icon. The system tokenizes the content in the Description of the field, matches the tokens with existing radicals, and recommends a field name. In the Radical-based Naming dialog box, you can replace the name of the selected field with the modified value.

      Note
      • If a suggested name does not meet your needs, you can modify it in the Revised Field Name input box.

      • Click Reset to revert the Revised Field Name to the system's matched radical.

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

    • Field constraint: Click the image icon to set constraints for the selected fields in batches.

      Important

      You cannot set field constraints for sub-dimension logical tables.

  2. Click Save and Next.

Import fields

  • Import from table

    1. On the configuration page of the fact logical 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 physical view (excluding parameterized views) in the current tenant for which you have read permissions.

      To learn how to obtain read permissions for a physical table, see Apply for, renew, and revoke 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 fields you add are displayed in this list. You can delete fields from this list.

    3. Click Add to import the fields from the physical table into the fact logical table.

      After the fields are added to the New Fields area, you can edit their name, data type, field category, and associated dimension based on your business requirements.

  • Import from DDL statement

    The source for measure fields depends on whether the fact logical table has a primary key. If a primary key is defined, you can select measure fields only from the primary source table. Otherwise, you can select them from both the primary source table and other data tables.

    1. On the configuration page of the fact logical table, click Import from DDL Statement.

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

    3. From the field list, select the fields you need and click Add to create new fields in the fact logical table.

Add an associated dimension

Associate foreign key fields in the fact attributes of the fact logical table with dimensions.

  1. On the configuration page of the fact logical table, click the gagag icon to open the Edit Model Relationship dialog box.

  2. In the Edit Model Relationship dialog box, configure the following parameters.

    Area

    Parameter

    Description

    Null replacement value

    If the foreign key field of the fact logical table fails to associate with the dimension table, the system sets the Default Value Setting to -110.

    Associated dimension

    Associated entity, Dimension logical table

    Select the associated entity and dimension logical table that you have already created.

    Edit association logic

    Association logic

    Select a field from the fact logical table and configure its relationship with the primary key of the dimension logical table to be associated.

    Dimension table versioning policy

    Select the version (partition) of the associated dimension table. By default, the partition version that shares the same cycle as the main table is used.

    Unmatched data policy

    This policy defines how to handle data that exists in the primary source table (left table) but not in the dimension logical table (right table) due to a failed join. You can choose between Keep original unmatched data and Replace unmatched data with default value:

    • Keep original unmatched data: When you create a derived metric, the original data from the left table is preserved.

    • Replace unmatched data with default value: If a field from the dimension table is not associated with the fact logical table, the default value -110 is used.

    Edit dimension role

    Role name (English), Role name

    A dimension role is an alias for a dimension. This allows the same dimension to be referenced multiple times in a model, each with a unique role name. You must define a Role name (English) and a Role name.

    • The Role name (English) defaults to the prefix dim. The custom part of the name must follow these rules:

      • Can contain letters, digits, and underscores (_).

      • Must be 64 characters or less.

    • The Role name must follow these rules:

      • Can contain Chinese characters, digits, letters, underscores (_), and hyphens (-).

      • Must be 64 characters or less.

  3. Click OK.

Step 3: Configure the calculation logic

  1. On the Calculation Logic page, configure the mapping between the source data and the primary key of the fact logical table.

  2. Click Source Configuration to open the Source Configuration dialog box, and in the Source Configuration dialog box, configure the source parameters.

    Note
    • Do not add extra filters for event time in the filter condition or custom SQL.

    • If the current logical table does not have a primary key, you can configure only one source. If the data comes from multiple tables, use custom SQL to join them beforehand.

    Parameter

    Description

    Source type

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

    Source table types:

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

    • Source without primary key: A logical table without a primary key can have only one source. If the data comes from multiple tables, use custom SQL to join them beforehand.

      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 (excluding parameterized views) in the current tenant for which you have read permissions.

      To learn how to get read permissions on a physical table, see Apply for, renew, and revoke table permissions.

    • Select Custom SQL: Click the image icon and enter your SQL query in the editor. For 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 in the current tenant for which you have read permissions.

      To learn how to get read permissions on a logical table, see Apply for, renew, and revoke table permissions.

      Important

      Using a logical table as a data source for another logical table increases the complexity of calculation logic and O&M. Use this option with caution.

    Object alias

    Define an alias for the source table, such as t1 or t2.

    Object description

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

    Filter condition

    Click the image icon and enter a filter condition in the editor. For example:

    ds=${bizdate} and condition1=value1

    Filter conditions are not available for custom SQL sources.

    Join 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 all fields.

  3. Click OK to finish configuring the source.

  4. After configuring the source, drag the source fields to map them to the calculation logic expressions.

    You can also click Quickly Map Fields with 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. Aggregate 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. 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. Based on the field constraints, the system creates quality rules for the current logical table in the Data Quality module. Here, you can set the rule strength to strong or weak. For more information, see Data table quality rules.

  2. Click Save and Next.

Step 5: Configure scheduling

  1. On the Scheduling and parameter configuration page, configure the Data delay, Scheduling properties, Scheduling dependencies, Scheduling parameters, and Runtime configuration for the fact logical table.

    Parameter

    Description

    Data delay

    If you enable data delay, the system automatically reruns all data for this logical table within the Maximum Delay Days period. For more information, see Configure data delay for a logical table.

    Scheduling properties

    Defines the scheduling method for the fact logical table in the production environment. You can configure the scheduling type, period, logic, and execution. For more information, see Configure scheduling properties for a logical table.

    Upstream dependency

    Dataphin uses these dependencies to execute workflow nodes in the correct order, ensuring timely and effective data generation. For more information, see Configure upstream dependencies for a logical table.

    Parameter configuration

    Assigns values to code variables, which are automatically replaced during scheduled runs. On the parameter configuration page, you can ignore a parameter or convert it to a global variable. For more information, see Configure runtime parameters for a logical table.

    Runtime configuration

    You can configure a task-level runtime timeout and a retry policy for task failures based on your business scenario. This helps prevent resource waste from long-running tasks and improves the reliability of task execution. For more information, see Configure runtime settings for a logical table

    Resource configuration

    You can configure a scheduling resource group for the current logical table task. When the task is scheduled, it uses the resource quota of this group. For more information, see Configure resources for a logical table.

Step 6: Save and submit

  1. After configuring the fact logical table, click Save and Submit. The system validates the Table structure, Calculation logic, Scheduling dependencies, and Runtime parameters. Review the Check results for any failed items and correct the configuration.

  2. After all checks pass, enter a submission note and click OK and Submit.

    During submission, Dataphin performs data lineage analysis and submission checks. For more information, see Standard modeling task submission notes.

Next steps

  • If the project is in Dev-Prod mode, you must 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, you can view and manage its tasks in the O&M Center. For more information, see O&M Center.