Mart Hierarchy Flatten
Applies to
Platform: Microsoft SQL Server · Snowflake · Databricks · Databricks dbt · Fabric Lakehouse · Oracle
Architecture: Data Mart
A Mart Hierarchy Flatten resolves a parent-child hierarchy in the Mart layer into one row per start row and level. Use it when you report along a hierarchy of unknown depth, for example an employee and every manager above. After each load, its table holds the complete paths of the selected start rows.
Fabric Warehouse does not support Mart Hierarchy Flatten. Validation reports the warning Model object has an unsupported model object type for the Fabric Warehouse platform., whose details name the missing recursive common table expressions.
Sources and relationships
A Mart Hierarchy Flatten reads one source twice:
- Data Mart: a Mart Composite of the project, or a linked Current View or Business Current View of a Data Vault project. A Data Mart project cannot import a BusinessVault Composite.
- Vault and Mart: Current View, Business Current View, BusinessVault Composite, Vault Out or Mart Composite.
- Dimensional and Mart (not on Databricks dbt and Oracle): Mart Composite.
In a Vault and Mart project, a BusinessVault Composite as source raises the validation warning ID-21002, see Composite model object from another layer (Business Rule). Its message refers to the Vault Out.
A Mart Hierarchy Flatten has no relationships. Mart Dimension, Mart Fact, Mart Composite and Mart Out can read it.
Create a Mart Hierarchy Flatten
There is no wizard. Create it manually:
- Create a model object of type Mart Hierarchy Flatten in the Data Mart column.
- Create a dataflow set and add the source twice:
s1, the first source of the dataflow set, stands for the row of the current level,s2for its parent. - Join
s2tos1on the parent key, for examples2.EMPLOYEE_ID = s1.MANAGER_ID. - Optionally, set a filter on
s1in the dataflow set. It selects the start rows. - Map the terms. Take the key of the start row from
s1and the values of the next level froms2. Give each term the name of a column of the source, because the start rows read the columns by name.
How the hierarchy is resolved
The source view is a recursive query:
- Start rows: every row of the source that passes the filter. Each term takes the column of the same name from the source, without the mapping expression.
- Next level: each row of the previous level takes the place of
s1and is joined to its parent ins2. The term mappings calculate the new row. The filter does not apply to the parents. - The query stops when no parent is found. Each start row therefore appears once per level of its path.
Terms that you do not map, such as BG_SourceSystem, are empty in the rows of the next levels.
Properties
- Implementation Type:
Cachedonly. The loader empties the table and inserts all rows of the source view on every load.
Default Terms
BG_LoadTimestamp: the load that wrote the rows.BG_SourceSystem: the value of the start row; empty in the next levels.
Generated objects
The part flow of Mart Hierarchy Flatten shows which parts it can get and under which settings; the legend explains the symbols.

These are the names on Microsoft SQL Server for a Mart Hierarchy Flatten employee_hierarchy:
| Role | Generated name | Purpose | Generated when |
|---|---|---|---|
| Source | DM_FlattenHierarchy_employee_hierarchy_Source | Recursive query | Always |
| Loader | DM_FlattenHierarchy_employee_hierarchy_Loader | Reloads the table | Always |
| Storage | DM_FlattenHierarchy_employee_hierarchy | Flattened table | Always |
| Result | DM_FlattenHierarchy_employee_hierarchy_Result | View for the readers | Create Result Views true |
Generated parts of model objects shows the order in which a load runs the parts and the settings that add or remove them.
Example
The Mart Hierarchy Flatten employee_hierarchy on Microsoft SQL Server reads the Mart Composite employee_manager twice. Its terms are mapped as follows:
EMPLOYEE_ID(business key):s1.EMPLOYEE_ID.LAST_NAME:CAST(CONCAT(s1.LAST_NAME, ' - ', s2.LAST_NAME) AS NVARCHAR(1000)), the path. The cast keepsNVARCHAR(1000), the data type ofLAST_NAMEin the Mart Composite, because a recursive query needs the same data types on every level.MANAGER_ID:s2.MANAGER_ID, the parent of the level reached. The next level joins on it.
The join is s2.EMPLOYEE_ID = s1.MANAGER_ID, and the filter s1.EMPLOYEE_ID in (401, 405, 416) selects the start rows. The Mart Composite is loaded before the Mart Hierarchy Flatten. Before the load at 10:00, it holds these rows:
EMPLOYEE_ID LAST_NAME MANAGER_ID 401 Keller NULL 405 Huber 401 416 Meier 405 420 Brunner 416
As a tree, with arrows from a manager to the employee who reports to them:

Check the result
Query the result view, here in the schema mart:
SELECT EMPLOYEE_ID, LAST_NAME, MANAGER_ID, BG_LoadTimestamp FROM mart.DM_FlattenHierarchy_employee_hierarchy_Result ORDER BY EMPLOYEE_ID, LEN(LAST_NAME);
This is the result after the load on 2026-10-28 at 10:00, with a shortened timestamp:
EMPLOYEE_ID LAST_NAME MANAGER_ID LoadTs 401 Keller NULL 2026-10-28 10:00 405 Huber 401 2026-10-28 10:00 405 Huber - Keller NULL 2026-10-28 10:00 416 Meier 405 2026-10-28 10:00 416 Meier - Huber 401 2026-10-28 10:00 416 Meier - Huber - Keller NULL 2026-10-28 10:00
- Employee 416 has three rows: the start row and one row for each manager above.
- Employee 420 is not a start row and does not appear.
- The table has no level column; the query orders the levels by the length of the path.
Before the load at 12:00, employee 405 changes the last name to Huber-Graf, and employee 416 now reports to 401. After that load, the result is:
EMPLOYEE_ID LAST_NAME MANAGER_ID LoadTs 401 Keller NULL 2026-10-28 12:00 405 Huber-Graf 401 2026-10-28 12:00 405 Huber-Graf - Keller NULL 2026-10-28 12:00 416 Meier 401 2026-10-28 12:00 416 Meier - Keller NULL 2026-10-28 12:00
The loader rebuilt the table, so the path of 416 skips 405 and no row of the first load remains.
Platform differences
The rules for names, loaders, deployment, platform properties and defaults are in Model object types on each platform. The Mart Hierarchy Flatten differs from them in these points:
- Snowflake: the flattened table is a transient table, and the load control task
LC_DM_FLATTENHIERARCHY_<model object name>_TASKcalls the loader. - Databricks and Fabric Lakehouse: there is no source view, so the Source row of the table does not apply. The loader notebook resolves the levels itself.
- Databricks dbt: the source model uses
WITH RECURSIVE. Foreign Key Mode is offered without effect. - Fabric Warehouse: not supported.
Limitations
- A Mart Hierarchy Flatten has exactly one dataflow with one dataflow set and no aggregation.
- It has no relationships and at least one term that is not a Default Term.
- Every term name must exist as a column of the source.
- On Microsoft SQL Server, the source view resolves at most 100 levels beyond the start rows, the default recursion limit of SQL Server. A longer path, or a cycle in the hierarchy, makes the load fail with SQL Server error 530,
The maximum recursion 100 has been exhausted before statement completion.The loader empties the table before it inserts, so the table stays empty until the next successful load.
Release differences
- Generator 1.10: Mart Hierarchy Flatten is available.
- Generator 2.0: Mart Hierarchy Flatten is available on Oracle.
- Generator 2.2: Mart Hierarchy Flatten is available on Databricks dbt.
Related articles
- Previous: Mart Composite
- Next: Mart Dimension, Mart Fact
- Reference: Implementation Type (Model Object), File Format (Model Object), BG_LoadTimestamp, BG_SourceSystem, Composite model object from another layer (Business Rule), Model object types on each platform, Generated parts of model objects
- See also: Hierarchy Flatten, Vault Out, Mart Out, Model a Data Mart Solution