Staging model
A staging model is the first layer of models in a dbt project. Each one reads one raw table, renames and casts its fields, and joins nothing. Later models read the staging model, not the raw table, so the cleanup happens in one place and every model downstream sees the same names and types.
In BlockJuice
In BlockJuice the staging models live in transformation/, one folder per source name. For an evm-* source the name is the chain, so staging/ holds the Ethereum views. Each folder declares its raw tables in _<name>__sources.yml.
Each model is a view named stg_<name>__<table>, such as stg_ethereum__erc20_transfers over raw.ethereum_erc20_transfers. It casts fields out of the jsonb data column and lowercases EVM addresses. Solana and Bitcoin addresses keep their case, because base58 is case-sensitive. A raw table that mixes kinds of record gets one view per kind, with a suffix such as _transactions or _traces.
The dbt source’s name and table match the name and table the ingestion source exports. That is how Dagster links each source to its staging view, and a test fails when a pair drifts apart.
Example
stg_ethereum__erc20_transfers, trimmed. Every field comes out of data with a cast, the addresses come out lowercased, and value stays in the token’s base units.
select
id,
(data ->> 'block_number')::bigint as block_number,
(data ->> 'timestamp')::timestamptz as block_timestamp,
data ->> 'tx_hash' as tx_hash,
lower(data ->> 'token') as token,
lower(data ->> 'from') as from_address,
lower(data ->> 'to') as to_address,
(data ->> 'value')::numeric as value
from {{ source('ethereum', 'erc20_transfers') }}