materialized
- Project YAML file
- Properties YAML file
- SQL file config
dbt_project.yml
config-version: 2
models:
<resource-path>:
+materialized: <materialization_name>
models/properties.yml
models:
- name: <model_name>
config:
materialized: <materialization_name>
models/<model_name>.sql
{{ config(
materialized="<materialization_name>"
) }}
select ...
Definition
Materializations are strategies for persisting dbt models in a warehouse. These are the materialization types built into dbt:
ephemeral— ephemeral models are not directly built into the databasetable— a model is rebuilt as a table on each runview— a model is rebuilt as a view on each runmaterialized_view— allows the creation and maintenance of materialized views in the target databaseincremental— incremental models allow dbt to insert or update records into atablesince the last time that model was run
You can also configure custom materializations in dbt. Custom materializations are a powerful way to extend dbt's functionality to meet your specific needs.
Creation precedence
Materializations are implemented following this "drop through" life cycle:
- If a model does not exist with the provided path, create the new model.
- If a model exists, but has a different type, drop the existing model and create the new model.
- If
--full-refreshis supplied, replace the existing model regardless of configuration changes and theon_configuration_changesetting.- BigQuery users may need to run
dbt run --full-refresh(instead ofdbt run) after changing a model’s materialization (for example, fromtabletoview) to ensure dbt fully replaces the existing relation and the change is fully applied.
- BigQuery users may need to run
- If there are no configuration changes, perform the default action for that type (e.g. apply refresh for a materialized view).
- Determine whether to apply the configuration changes according to the
on_configuration_changesetting.
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
0