A hierarchy dimension logical table is a dimension table with hierarchical relationships. For example, a time-based hierarchy dimension logical table contains date data such as day, week, month, quarter, and year.
Introduction to hierarchy dimension tables
A hierarchy dimension table corresponds to a hierarchy object with the following features:
-
Small data volume.
-
The data (rows) have a hierarchical relationship in a business context. Examples include administrative regions, enterprise organizational structures, and product categories. Countries, provinces, and cities are independent records, but they have a hierarchical relationship: Country -> Province -> City. Other examples are an enterprise organizational structure, such as Business Group -> Business Unit -> Primary Department -> Secondary Department, and product categories, such as Food -> Snacks -> Dried Fruit.
Example
Data pattern
Hierarchical data in business systems typically follows this pattern.
|
Field name |
Field description |
|
id |
Current level ID. |
|
name |
Current level name. |
|
parent_id |
Parent level ID. |
|
level |
Level. |
Data example
The region data table in a business system.
|
id |
name |
parent_id |
level |
|
1 |
China |
Null |
0 |
|
21 |
East China |
1 |
1 |
|
212 |
Zhejiang Province |
21 |
2 |
|
2121 |
Hangzhou City |
212 |
3 |
|
21213 |
Yuhang District |
2121 |
4 |
The hierarchy dimension table created from the Dataphin region business object.
|
Logical table name |
Business object |
Source table |
Child field |
Parent field |
Name field |
Number of levels |
|
dim_region |
region |
${xxx}.region |
id |
parent_id |
name |
5 |
Prerequisites
A hierarchy business object must be created. For more information, see Create and manage business entities.
Procedure
-
On the Dataphin home page, choose Development > Data Development from the top menu bar.
-
From the top menu bar, select a Project. If you are in Dev-Prod mode, you must also select an Environment.
-
In the navigation pane, choose Standard Modeling > Logical Dimension Table.
-
In the list of logical dimension tables, click the
New icon. -
In the Create Logical Dimension Table dialog box, configure the parameters.
Parameter
Description
Business Object
Select Hierarchical Object. For example, the
regionbusiness object.Table Type
If you select Hierarchical Object for the business object, the table type is automatically set to Hierarchy Dimension Logical Table and cannot be changed.
Data Section
The default value is the business unit associated with the project. This parameter cannot be changed.
Data Domain
The default value is the data domain of the business object. This parameter cannot be changed.
Compute engine
If the Dataphin instance uses the Hadoop compute engine, you can select a compute engine for the tenant. Options include Hive, Impala, and Spark.
Important-
The compute engine must be enabled before you can select it. For more information, see Create a Hadoop compute source.
-
If the compute engine is TDH 6.x or TDH 9.3.x, you cannot configure this parameter.
The compute engine has the following limits:
-
Hive: Cannot read source tables in Kudu format.
-
Impala: Can read source tables in Kudu format, but does not support storing logical tables in Kudu format. Do not use Impala if you do not have source tables in Kudu format.
-
Spark: Cannot read source tables in Kudu format.
Data Timeliness
Scheduling type for the hierarchy dimension logical table task in the production environment. Defaults to T+1 (daily task).
Logical Table Name
Dataphin automatically fills in the logical table name. The default naming convention is
{Business Unit Name}.dim_{Business Object Name}.Chinese Name
Enter a Chinese name for the dimension logical table. For example, Regional Dimension Logical Table.
The naming conventions are as follows:
-
The name cannot exceed 128 characters in length.
-
All characters are supported.
Description
Enter a brief description of the hierarchy dimension logical table. The description can be up to 1,000 characters in length.
-
-
Click OK.
-
On the Computation Logic page, configure the mapping between the source data and the primary key of the dimension logical table.
Parameter
Description
Column Name
The default value is the name of the business process. You can also change the field name. For example,
region.The naming conventions are as follows:
-
The name cannot exceed 128 characters in length.
-
All characters are supported.
Data Type
Select the data type of the primary key for the hierarchy logical table. For example,
bigint.Description
Enter a description for the primary key field of the hierarchy logical table. For example,
Region_Primary_KeyID.Source Table
Select the data source for the hierarchy dimension. For example, the
regiondata table.Number Of Levels
Configure the number of levels for the hierarchy dimension. For example,
5.Generate Leaf Dimension Table
Specify whether to generate a leaf-level dimension table, which represents the most detailed level in the hierarchy. For example, a product category leaf-level table contains specific product details such as product ID, name, price, inventory, and sales quantity.
Child Field, Parent Field
Select the data fields in the source table that represent the child and parent levels. For example, the
id(child field) andparent_id(parent field) in theregiondata table.Column Name
Select the data field in the source table that represents the name of the hierarchy dimension table field. For example, the
namefield in theregiondata table.Root Node Definition
Define the record that corresponds to the root node of the hierarchy. You can define an SQL condition based on the fields of the main source table to identify the root level. For example, in the
regiondata table, China is the root node. The condition can belevel = 0orparent_id is null.Filter Condition
Optional. Define a filter condition for the source table fields to filter out dirty data or logically deleted fields.
NoteYou can define conditions for data updates and retrieval periods, which are time partitions, only based on the fields of the main source table.
-
-
Click Save And Next.
-
On the Scheduling & Parameter Configuration page, configure the dimension logical table by setting Scheduling Properties, Scheduling Dependencies, Scheduling Parameters, and Runtime Configuration:
-
Scheduling Properties: Defines how the dimension logical table is scheduled in the production environment, including the scheduling type, period, logic, and execution. For more information, see Configure scheduling properties for a logical table.
-
Scheduling Dependencies: Defines the scheduling node of the logical table. Dataphin runs nodes in a business flow based on configured dependencies, ensuring that business data is generated on time. For more information, see Configure upstream dependencies for a logical table.
-
Runtime Parameters: Assigns values to variables in the code so that parameter variables are automatically replaced with their corresponding values during node scheduling. On the scheduling parameter configuration page, you can Ignore a parameter configuration or Convert It To A Global Variable. For more information, see Configure parameters for a logical table.
-
Runtime Configuration: Sets a task-level runtime timeout and a rerun policy for failed tasks, preventing resource waste from long-running tasks and improving execution reliability. For more information, see Configure the runtime properties of a computing task.
-
Resource Configuration: Specifies the scheduling resource group for the logical table task. The task consumes the resource quota of this group when scheduled. For more information, see Configure resources for a logical table.
-
-
After you configure the hierarchy dimension logical table, click Save And Submit.
When you submit the task, Dataphin parses the data lineage and performs a submission check. For more information, see Submission description for standard modeling tasks.
What to do next
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 the logical table task in the Operation Center. For more information, see Operation Center.