Skip to content
  • There are no suggestions because the search field is empty.

Hierarchy Flatten

Applies to
Platform: Microsoft SQL Server · Snowflake · Snowflake dbt · Databricks · Databricks dbt · Fabric Lakehouse · Oracle
Architecture: Data Vault

A Hierarchy Flatten resolves a parent-child hierarchy into one row per ancestor and descendant, at every level, in a table of the Business Vault layer. Use it to report on multi-level hierarchies such as bills of materials or organization charts without recursive queries. After each load, the table holds the complete flattened hierarchy of the current data.

Fabric Warehouse does not support Hierarchy Flatten. Validation reports the warning Model object has an unsupported model object type for the Fabric Warehouse platform. Its details name the missing recursive common table expressions, see Model object type not supported on Fabric Warehouse (Business Rule).

Sources and relationships

A Hierarchy Flatten reads a Current View or a BusinessVault Composite that holds the parent-child pairs, usually a Current View on a Hierarchical Link and its Link Satellite. It has one dataflow with one dataflow set, and the dataflow set contains the same source twice. Only these Business Vault types can read it: Business Hub, Business Link, Business Satellite, Business Link Satellite, BusinessVault Composite and Vault Out. The other Business Vault types, for example Business Driving Key Link and Effectivity Business Satellite, cannot read it. In a Vault and Mart project, Mart Dimension, Mart Fact and Mart Composite can read it too.

Create a Hierarchy Flatten

There is no wizard. Create it manually:

  1. Create a model object of type Hierarchy Flatten in the Business Vault column.
  2. Create a dataflow set and add the source twice, as s1 and s2.
  3. Set the join of s2: its parent key equals the child key of s1, for example s2.common_item_parent_HK = s1.common_item_child_HK.
  4. Map the terms: the parent terms from s1, the child terms and the other terms from s2.

How the hierarchy is resolved

The generator builds the flattening from the dataflow set:

  • Each row of s1 is a starting pair, taken as it is. A where clause of the dataflow set filters these starting rows.
  • For each pair found so far, the join to s2 finds the children of its child, again and again until no level is left.
  • Each found row keeps the parent of the starting pair and takes the child and the other mapped terms from s2.

The result has one row for every ancestor and each of its descendants.

Properties

Default Terms

Generated objects

The part flow of Hierarchy Flatten shows which parts it can get and under which settings; the legend explains the symbols.

Part flow of Hierarchy Flatten, top to bottom. The main path on the left, with the default settings, runs _Source, _Loader, Table, _Result. Decisions with their values, the default or main value first: Before-load rule (no; yes); Create Result Views (true; false); Logging (yes). Detours add the other parts: _DataQualityLoader, _DataQualityTable, _DataQualityResult, _DataQualityBeforeLoadAction, _DataQualityError.

These are the names on Microsoft SQL Server for the Hierarchy Flatten flatten_bom:

RoleGenerated namePurposeGenerated when
SourceBDV_FlattenHierarchy_flatten_bom_SourceFlattens the hierarchyAlways
DataQualityLoaderBDV_FlattenHierarchy_flatten_bom_DataQualityLoaderChecks the rules and fills the data quality tableAn active rule that runs before the load
DataQualityStorageBDV_FlattenHierarchy_flatten_bom_DataQualityTableHolds the rows and their check resultsAn active rule that runs before the load
DataQualityBeforeLoadActionBDV_FlattenHierarchy_flatten_bom_DataQualityBeforeLoadActionApplies the rule actions before the loadAn active rule that runs before the load
IntermediateResultBDV_FlattenHierarchy_flatten_bom_DataQualityResultPasses the rows to loadAn active rule that runs before the load
ErrorBDV_FlattenHierarchy_flatten_bom_DataQualityErrorHolds the rows that break a ruleAn active rule with Logging
LoaderBDV_FlattenHierarchy_flatten_bom_LoaderEmpties and fills the tableAlways
StorageBDV_FlattenHierarchy_flatten_bomHierarchy Flatten tableAlways
ResultBDV_FlattenHierarchy_flatten_bom_ResultQuery viewCreate Result Views true
  • The source view is a recursive query (WITH common table expression).
  • There is no delta view: the loader truncates the table and inserts all rows of the source view.

Generated parts of model objects shows the order in which a load runs the parts and the settings that add or remove them.

In the native load control, the loader depends on the loaders of the Hierarchical Link and the Link Satellite behind the Current View, so it runs after them.

Example

The Hierarchy Flatten flatten_bom on Microsoft SQL Server reads the Current View bom_current twice. That view combines the Hierarchical Link bom between parent and child items of the Hub common_item with the Link Satellite bom_lsat, which stores the QUANTITY. The bill of materials is:

  • Item 1, a burger menu, contains item 2, a burger, and item 3, fries.
  • Item 2 contains item 4, a bun, and item 5, a patty.
  • Load 1 on 2026-10-28 08:00 delivers quantity 1 for every pair. Load 2 on 2026-10-29 08:00 changes the patty quantity of the burger to 2. Load 3 on 2026-10-30 08:00 delivers the same data.

As a tree, with arrows from a parent item to its child items:

Bill of materials of the example as a tree: item 1, the burger menu, has the children item 2, the burger, and item 3, the fries. Item 2 has the children item 4, the bun, and item 5, the patty.

After load 2, the Current View holds these pairs, with the column names shortened:

PARENT_ID  CHILD_ID  QUANTITY
1          2         1
1          3         1
2          4         1
2          5         2

Check the result

Query the result view, here in the schema bv:

SELECT FK_common_item_parent_ITEM_ID AS PARENT_ID,
       FK_common_item_child_ITEM_ID AS CHILD_ID,
       QUANTITY, BG_LoadTimestamp
FROM bv.BDV_FlattenHierarchy_flatten_bom_Result
ORDER BY PARENT_ID, CHILD_ID;

This is the result after load 3:

PARENT_ID  CHILD_ID  QUANTITY  BG_LoadTimestamp
1          2         1         2026-10-30 08:00
1          3         1         2026-10-30 08:00
1          4         1         2026-10-30 08:00
1          5         2         2026-10-30 08:00
2          4         1         2026-10-30 08:00
2          5         2         2026-10-30 08:00
  • The four pairs of the bill of materials appear as they are. Item 1 also gets its indirect children 4 and 5.
  • QUANTITY comes from s2, the last level: the pair 1 and 5 shows 2, the quantity of the patty in the burger. Quantities are not multiplied across levels.
  • Every load replaces all rows, so all rows carry the timestamp of load 3.

Platform differences

The rules for names, loaders, deployment, platform properties and defaults are in Model object types on each platform. The Hierarchy Flatten differs from them in these points:

  • Snowflake: the table is a transient table, and the load control task LC_BDV_FLATTENHIERARCHY_<model object name>_TASK calls the loader.
  • Databricks and Fabric Lakehouse: there is no source view. The loader notebook calculates the hierarchy and fills the table.
  • Snowflake dbt and Databricks dbt: the source model uses WITH RECURSIVE.
  • Fabric Warehouse: not supported.

Limitations

  • A Hierarchy Flatten has exactly one dataflow and one dataflow set, no aggregation, at least one term besides the Default Terms and exactly one identity term, BG_DataQuality_ID. Validation reports an error otherwise.
  • The dataflow set contains exactly two source model objects, s1 and s2.
  • The table holds no history; each load replaces it.
  • On Microsoft SQL Server, the source view resolves at most 100 levels below the starting pairs, the default recursion limit of SQL Server. A deeper hierarchy, or a cycle in it, 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 2.2: Hierarchy Flatten is available on Databricks dbt.
  • Generator 2.4: Hierarchy Flatten is available on Snowflake dbt, the first release of that generator.

Related articles