dbt can build models as views, tables, or incremental tables, and increasingly the materialized_view materialization — which leverages the warehouse's native materialized view directly — is making its way into production.
It only works when the adapter (e.g., dbt-snowflake, dbt-databricks) supports it, and DDL restrictions and refresh behavior follow each warehouse's specification. For exam prep, the key is to clearly separate what dbt is responsible for from what the warehouse is responsible for.
dbt's materialized_view materialization is a wrapper that lets the adapter create a warehouse-native materialized view. dbt handles the surrounding concerns — the DAG, dependencies, schema naming, grants — while the actual data persistence and incremental refresh are delegated to the warehouse's engine and maintenance layer.
Support status and restrictions vary by warehouse. Snowflake automatically maintains materialized views as a service, with restrictions like no non-deterministic functions and limits on referencing other views. Databricks also offers Materialized Views, maintained incrementally in the background. In every case, check the latest official documentation for the CREATE/ALTER specifications.
How dbt relates to a warehouse-native materialized view
Snowflake materialized views are auto-maintained and incrementally refreshed in response to base-table changes. Non-deterministic functions and references to other views are restricted, and periodic maintenance consumes credits. You can suspend and resume auto-maintenance, or perform a rebuild-style operation, as needed.
Databricks materialized views are maintained in the background based on the declaratively defined SELECT. You can explicitly trigger a rebuild (the REBUILD equivalent), and queries must be deterministic. DDL and restrictions vary across versions and editions, so check the official documentation before adoption.
Choose based on read latency, refresh frequency, cost, and DDL restrictions. Materialized views accelerate reads and auto-maintain deltas, but they offer less SQL flexibility than tables and incur maintenance cost. Incremental tables give you full control on the dbt side, but designing and validating the update logic is more work.
| Approach | Refresh | Storage | Constraints / flexibility |
|---|---|---|---|
| view | Recomputed per query (cache-dependent) | Effectively none | Most flexible; heavy aggregations are slow |
| materialized_view | Warehouse auto-maintains incrementally | Yes (storage + maintenance cost) | DDL/SQL restrictions; determinism required |
| table | Manual rebuild / swap | Yes | Flexible, but updates are batch-centric |
| incremental (dbt) | Delta UPSERT via dbt logic | Yes (depends on job runtime) | Flexible but heavier to implement and validate |
Set materialized='materialized_view' on the dbt model. If the adapter supports it, CREATE MATERIALIZED VIEW (or the equivalent DDL) will be issued. --full-refresh may be unsupported or treated as a rebuild for materialized views, so verify per-environment behavior before running.
Dependencies are managed with ref as usual. Tests and documentation are bound to the model name, and dbt test runs SELECT against the materialized view that was created. Grants are also applied if the adapter supports them.
Sample dbt model definition (Snowflake / Databricks; subject to your runtime constraints)
-- models/mv_orders_daily.sql
{{ config(
materialized = 'materialized_view',
tags = ['core', 'mv'],
persist_docs = {'relation': true, 'columns': true}
) }}
-- Note: avoid non-deterministic functions and references to other views
select
o.customer_id,
cast(o.order_date as date) as order_date,
count(*) as orders,
sum(o.total_amount) as revenue
from {{ ref('stg_orders') }} as o
where o.order_status = 'completed'
group by 1, 2;
# schema.yml (excerpt)
version: 2
models:
- name: mv_orders_daily
description: Daily order aggregation (materialized view). Auto-maintained by the warehouse to keep read latency low.
tests:
- not_null:
column_name: customer_id
- not_null:
column_name: order_date
config:
grants:
select: ['bi_reader']
# Operational helpers (verify Databricks / Snowflake DDL for your environment)
-- Snowflake example (suspend / resume auto-refresh)
-- ALTER MATERIALIZED VIEW <db>.<schema>.mv_orders_daily SUSPEND;
-- ALTER MATERIALIZED VIEW <db>.<schema>.mv_orders_daily RESUME;
-- Databricks example (rebuild)
-- ALTER MATERIALIZED VIEW <catalog>.<schema>.mv_orders_daily REBUILD;Refresh is owned by the warehouse. Maintenance running during peak hours affects credit/DBU consumption and concurrent execution, so consider scheduling or pausing auto-maintenance to fit your SLA. Trigger rebuilds explicitly with DDL.
Schema changes may require a replacement (CREATE OR REPLACE) or rebuild. Swapping via dbt run triggers a background rebuild, and stale results may be served for a brief window. For critical queries, we recommend canary comparisons and pre-validation in a staging environment.
The dbt Analytics Engineer exam tests your understanding of materialization selection criteria, ref / source management, tests / documentation, and environment separation. You will benefit from clearly articulating the role split: materialized_view is a "view incrementally maintained by the warehouse," while dbt itself sits as an ETL / ELT execution framework that issues the DDL.
In practice it is especially effective for reducing query load during spikes and stabilizing dashboard response times. When you need highly flexible transformations or non-deterministic logic, fall back to incremental or table instead.
Analytics Engineer
問題 1
You need to deliver a frequently-read daily aggregation with low latency. The SQL is deterministic and the warehouse supports materialized views. Which approach is best in dbt?
正解: A
The requirement is low latency with deterministic SQL. If the warehouse supports it, materialized_view accelerates reads via automatic incremental maintenance. view tends to be slow for heavy aggregations, while full table swaps and full-recompute incremental are both inefficient.
Why do I get an error when I set materialization to materialized_view in dbt?
The adapter may not support it, or your model's SQL may violate warehouse-side materialized view constraints (non-determinism, references to other views, etc.). Check the adapter's documentation and the warehouse's CREATE MATERIALIZED VIEW restrictions.
Can I rebuild a materialized view with full-refresh?
It depends on the environment. Some adapters do not support full-refresh, while others effectively rebuild via CREATE OR REPLACE. Validate ahead of time and fall back to explicit DDL (SUSPEND/RESUME, REBUILD, etc.) when needed.
Can grants be applied to a materialized_view?
Yes, as long as the adapter supports grants. Configure grants in the dbt config to give roles SELECT and other privileges. If the adapter does not support it, fall back to post-hook or manual DDL.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
dbt Models: SQL-Defined Transformation Units (2026)
Model fundamentals — SELECT-based definitions, naming, refs,...
dbt Analytics Engineering Exam: Complete Guide (2026)
Pass the AE Certification — scope, weighting, sample questio...
dbt Cloud vs dbt Core: Feature & Cost Comparison (2026)
Honest comparison of dbt Cloud vs. dbt Core — IDE, scheduler...
dbt Project Structure: models/seeds/macros Layout (2026)
Recommended dbt project layout — models, seeds, macros, snap...
dbt_project.yml Explained: Every Config (2026)
Every dbt_project.yml setting that matters — paths, vars, ma...