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

Databricks dbt Data Vault and Mart

Applies to
Platform: Databricks dbt
Architecture: Data Vault · Data Mart

Databricks dbt Data Vault and Mart generates a Stage, Raw Vault, Business Vault and Mart for Databricks as one dbt project. Select the Generator Configuration Databricks Dbt Data Vault & Mart when you add a project whose Mart reads the Data Vault of the same project instead of a linked project.

The vault objects behave as described in Databricks dbt Data Vault, the Mart objects as in Databricks dbt Data Mart; this article covers what changes when both are in one project. The configuration offers no load control, no deployment scripts and no data quality checks.

Scope and output

  • Platform: Databricks with Unity Catalog. The configuration is available since Generator 2.2; Generator 2.1 contained a preview.
  • Dataflow Modeling columns: Source; Stage under Bronze; Raw Vault and Business Vault under Silver; Datamart under Gold with the Mart model objects, shown as Data Mart in the diagram. See Understand the Layering concept.
  • Deployment layers: Stage, Raw Vault, Business Vault and Mart.
  • Output: one dbt project with the model folders models/stage, models/rawvault, models/businessvault and models/mart, described in dbt - Artifacts. dbt creates and loads the tables, see dbt - Deployment.

Solid arrows are dataflows between the Dataflow Modeling columns of the project; dashed outlines mark columns of linked projects, and dashed arrows are their dataflows:

Layer flow of a Data Vault and Mart project: data flows from Source into Stage and from Stage into Raw Vault. Raw Vault feeds Business Vault and Data Mart, and Business Vault feeds Data Mart. From linked projects, Raw Vault can also read Stage, Data Store or Raw Vault objects, Business Vault can read Raw Vault or Business Vault objects, and Data Mart can read Data Store, Raw Vault, Business Vault or Data Mart objects.

Prerequisites

  • A Databricks workspace with Unity Catalog, dbt Core with the adapter dbt-databricks, and a connection profile, as described in Databricks dbt - Target environment. Databricks dbt is tested with dbt Core 1.x; dbt 2 is not verified.
  • The values in dbt_project.yml, listed in dbt - Placeholder values.

How the Mart reads the vault

dbt writes each layer into the schema <profile schema>_<layer schema> in the catalog of the connection profile. <profile schema> is the schema of the profile. <layer schema> is the +schema value of the layer in dbt_project.yml.

The Mart models read the vault models with ref(), not as dbt sources. Therefore one dbt run builds Stage, Raw Vault, Business Vault and Mart in dependency order, and each Mart model runs after the vault models it reads. The project needs no linked project and no variables for the vault, unlike Databricks dbt Data Mart.

With Create Result Views off (default), the Mart models read the vault tables and views, for example rdv_lsat_<model object name>. With it on, they read the result view of a vault object that has one, for example rdv_lsat_<model object name>_result.

Sources of the Mart objects

  • Source systems have the type Spark, see Discover a Databricks Unity Catalog.
  • The Mart objects read the Raw Vault and Business Vault objects of the project, Vault Out and other Mart objects. They cannot read Source or Stage objects. The article of each Mart object lists the model object types it accepts.
  • Vault Out is a source of Mart Composite, Mart Dimension, Mart Fact and Mart Hierarchy Flatten since Generator 2.2.

You can import a linked project as a source. dbt reads its objects as dbt sources of the linked source system.

Supported model objects

Source, Stage, Raw Vault and Business Vault: the model object types listed in Databricks dbt Data Vault, including Vault Out.

Mart:

Capabilities and limitations

  • Loading: dbt runs the models of all layers in the order of their references. Vault objects and Mart Facts with more than one dataflow get one loader model per dataflow.
  • Incremental reads: a vault model, or a Mart Fact with the Fact Load Strategy Insert that reads a vault object, reads only new rows when BG_IncrementalFilter is mapped to the source's BG_LoadTimestamp. See Configure an incremental load. Such a Mart Fact compares the BG_LoadTimestamp of the vault object with the latest BG_LoadTimestamp in its own table. The Mart Fact reads every new vault row. For the effect of a full refresh on Mart Facts, see dbt - Full refresh.
    • Run the vault and the Mart Fact in the same dbt run or one after the other: when a separate vault run starts before a Mart Fact run and ends after it, the Mart Fact can skip rows of that vault run.
    • Without an incremental read filter, a Mart Fact with the Fact Load Strategy Insert inserts all source rows again on every run.
  • Historization: Mart Dimensions with SCD2 terms allow one dataflow.
  • Validity: historized satellites and Mart Dimensions with SCD2 terms need Persist Validity or Create Result Views. With both off, validation reports an error that blocks generation, see Historization without result views or persisted validity.
  • Keys: the model YAML files declare primary keys, unique constraints on business keys and, with Foreign Key Mode Create Disabled (default), foreign keys. In the Mart only Mart Facts get foreign keys, to the Mart Dimensions they reference. No foreign key points from a Mart object to a vault object. Foreign Key Mode offers None and Create Disabled.
  • Hashes: Hash Algorithm offers only SHA-256. Hash keys and row hashes have the data type binary.

The properties that Databricks dbt Data Vault and Databricks dbt Data Mart list as not available are missing here too, among them the load control properties, Load Caching and Use Embryo Loader (see Embryo Loader).

Project properties

Project Settings shows the project properties of Databricks dbt Data Vault with the same defaults, among them Persist Validity on, Create Result Views off and Use Unique Constraints on.

Data types

Default Term data types by platform lists the data types of the Default Terms on Databricks dbt.

Platform differences

The table compares the configuration with Databricks Data Vault and Mart of the same release:

ItemDatabricks dbtDatabricks
Outputdbt project with SQL modelsPySpark notebooks, deployment scripts
Load controlnone, dbt runs the modelsMulti-Threading Notebook, Airflow
Create Result Views defaultoffon
Target Object Comment Type value Tablesnot availableavailable
Unity Catalogalways usedproperty Use Unity Catalog

Example

A Mart Dimension common_salestransaction reads the Link Satellite SALESTRANSACTION of the Raw Vault. Its model dm_md_common_salestransaction_source reads the vault model with ref(). Excerpt without the other columns:

    SELECT
         CAST(NULL AS String) AS `bg_sourcesystem`
        ,`s1`.`link_hk` AS `link_hk`
    FROM {{ ref('rdv_lsat_salestransaction') }} AS `s1`

List the models that a run of this dimension includes:

dbt ls --select +dm_md_common_salestransaction --output name

dbt lists 26 models and five source tables. The models are the Mart Dimension, the Link Satellite, its Link, five Hubs and five Stage objects, each with its _source model. dbt run with the same selection builds the Stage models first, then the Raw Vault models, then the Mart Dimension.

With Create Result Views on, the excerpt reads ref('rdv_lsat_salestransaction_result').

Release differences

Project Settings shows the Generator Version of your project.

  • Generator 2.2: first release after the preview in Generator 2.1. Compared with the preview: Vault Out, also as a source of the Mart objects; Create Result Views, default off; the Foreign Key Mode value Create Disabled with primary key and foreign key constraints; the incremental read filter on BG_LoadTimestamp; loaders for more than one dataflow; Reference Tables without an unknown-member row.
  • Generator 2.3: the catalog and schema of each source system are variables in dbt_project.yml; the model object property Custom Singleton Values; a fix of the Mart Out deduplication. See Generators Release - 2.3.0.
  • Generator 2.4: Non-Historized Satellite and Non-Historized Business Satellite; Excluded from Delta Detection; Use Unique Constraints; the materializations apply the constraints; table columns use the modeled data types. See Generators Release - 2.4.0.
  • Generator 2.4.1: Driving Key Links and Business Driving Key Links with more than one dataflow no longer report the validation warning ID-10065. The generated models stay the same. See Generators Release - 2.4.1.

Related articles