View materialization in dbt is an option that quickly provides a logical transformation layer without consuming storage. Because it is recomputed at every query, it suits lightweight shaping, normalization, column renaming, and type casting.
This article assumes stable behavior based on dbt's official documentation and organizes exam-prone knowledge alongside field operations essentials. It also covers common cautions across major DWHs such as Snowflake, BigQuery, Redshift, and Databricks.
Setting a dbt model to materialized: view defines it as a CREATE VIEW (CREATE OR REPLACE VIEW in many environments) in the adapter's dialect. Data is not stored; the query runs each time the view is referenced. Note that view is the default materialization for models, and that fact is frequently asked on exams.
dbt resolves dependencies via ref/source and controls build order. Views replace their definitions on rebuild, so code changes propagate quickly, but downstream query costs depend on the underlying tables' scan volume. Whether privileges and comments are retained is adapter-dependent, so it is safer to explicitly apply them via grants/persist_docs.
Minimal view model (models/stg_orders.sql)
{{ config(
materialized='view',
alias='stg_orders',
schema='staging'
) }}
select
cast(id as string) as order_id,
cast(customer_id as int) as customer_id,
order_date,
status
from {{ source('raw', 'orders') }}Views do not grow storage on build, but they recompute on the underlying engine every time they are referenced. The main cost drivers are compute credits on Snowflake, scanned bytes on BigQuery, and cluster time on Databricks. For lightweight transformations, delegating the transforms to views and persisting only downstream tables tends to be cost-optimal.
When heavy joins or large aggregations occur frequently, consider persisting with table or incremental. ephemeral is inlined into upstream models so no DB object is created; from a debugging and grants perspective, views are often easier to work with.
| Materialization | Entity | Refresh Timing | Storage |
|---|---|---|---|
| view | No stored data (view definition) | Recomputed on reference | Near 0 |
| table | Stored as a table | Fully recomputed on dbt run | Medium to large |
| incremental | Incremental writes to a table | Only when the delta is computed | Medium to large (delta accumulation) |
| ephemeral | No DB object (expanded as CTE) | Inlined into upstream at compile time | 0 |
Example of switching defaults per layer in dbt_project.yml
models:
staging:
+materialized: view
+tags: [staging]
marts:
+materialized: table
+tags: [marts]
Standardize the staging layer right after sources as views, and stabilize downstream models with column normalization, type casting, and simple filters. Delegate heavy joins and window aggregations to table/incremental in the marts layer to avoid concentrating query costs.
For permissions, use dbt's grants config to automatically grant read roles. On Snowflake, adapter-specific config lets you choose SECURE VIEW. BigQuery Authorized Views and Databricks Unity Catalog privileges are typically combined with a post-creation permission-granting operation.
View placement as a lightweight transformation layer
Lightweight shaping view in the staging layer (models/stg_customers.sql)
{{ config(materialized='view', alias='stg_customers') }}
select
cast(c.customer_id as int) as customer_id,
trim(lower(c.email)) as email_normalized,
coalesce(nullif(c.country, ''), 'UNKNOWN') as country,
c.created_at
from {{ source('raw', 'customers') }} c
where c.is_deleted = falseBecause views recompute every time, costs and latency accumulate on heavy joins, large aggregations, and high-frequency access. Switch such cases to table or incremental and, if needed, consider table-side optimizations such as clustering, sort keys, or Z-ORDER (varies by environment).
A dbt view is different from each DWH's “materialized view.” dbt's materialized: view is a regular view definition and does not persist results. To use the materialized-view feature, you need separate implementation/management aligned with the adapter and operations policy.
Switch heavy processing to table/incremental (models/agg_sales.sql)
{{ config(
materialized='incremental',
unique_key='order_id',
incremental_strategy='insert_overwrite'
) }}
with base as (
select * from {{ ref('stg_orders') }}
)
select
order_id,
date_trunc('day', order_date) as order_day,
count(*) as order_cnt
from base
{% if is_incremental() %}
where order_date >= dateadd('day', -7, current_date)
{% endif %}
group by 1,2On most adapters, views are redefined as CREATE OR REPLACE. Adding columns or changing expressions takes effect immediately, but breaking changes will fail if downstream consumers depend on specific columns. Detect breaking changes early through curation, tagging, PR checks, and dbt test.
Retention of permissions and comments is environment-dependent. It is safer to configure dbt's grants and persist_docs (subject to adapter support) and reliably apply them after the build. For adapter-specific options such as Snowflake SECURE VIEW, follow each environment's documentation.
Permission and doc propagation on views (excerpt from dbt_project.yml)
models:
staging:
+materialized: view
+grants:
select: ['ANALYST_ROLE']
+persist_docs:
relation: true
columns: true
Lock in: 1) view is the default model materialization, 2) views recompute each time and suit lightweight transforms, 3) heavy processing and high-frequency reference go to table/incremental, 4) ephemeral does not create a DB object, 5) grants/persist_docs depend on adapter support, 6) a dbt view is not the same as a DWH materialized view.
Exercise: separate staging as view and marts as table, and pin the staging schema with dbt test. When downstream queries are expensive, documenting the criteria for switching marts to incremental — based on execution plans and scan volume — pays off both in the field and on the exam.
CLI examples (selective run and tests)
# Build only the staging views
$ dbt run -s tag:staging
# Rebuild only downstream marts
$ dbt run -s tag:marts
# Run tests on important columns
$ dbt test -m stg_orders stg_customersAnalytics Engineer
問題 1
You want to apply only column normalization and light filtering on a frequently referenced source table while avoiding storage growth. Downstream, heavy aggregations will be persisted as separate tables. Which dbt materialization is best for the staging model?
正解: A
view is optimal when you want lightweight transformations without growing storage and immediate propagation of definition changes. table/incremental consume storage, and ephemeral creates no DB object, which makes granting permissions and independent referencing difficult.
Is a view recomputed every time? Does caching help?
Yes. A view itself does not store results. The DWH's query cache or result cache may shorten the recomputation, but guarantees and retention conditions depend on each DWH implementation. Design with recomputation as the baseline assumption.
Can I set indexes or clustering on a view?
Generally you cannot set them directly on a view. Physical optimizations are applied to the underlying tables, or to models persisted as tables. For high-frequency, heavy workloads, consider switching to table or incremental.
Can dbt handle Snowflake SECURE VIEW or BigQuery Authorized View?
The Snowflake adapter supports creating SECURE VIEWs via config (subject to environment privileges). BigQuery Authorized Views require dataset-level permission operations: grant appropriate access after the view is created. Follow each official documentation for details.
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...