Skip to content

DBT: Dbt Entity Owners

DBT model name: dbt_entity_owners

Explore dependencies/lineage: link


Description

Normalized dbt owners: one row per (entity, owner), exploded from the JSON-array owner on Elementary's dbt_models + dbt_sources. Mirrors dbt_entity_tags: exists so Metabase Field Filters (which require a scalar column, one value per row) can drive multi-select "is any of" owner filtering on the monitoring dashboards — the owner array can't back a Field Filter. Owners only apply to models/sources (not tests).


Details

Column Type Description
unique_id `` dbt unique_id (join key, e.g. model.trase_duckdb.).
name `` Model/source name.
kind `` 'model' or 'source'.
schema_name `` dbt schema the entity materializes into.
s3_location `` meta.s3_location of the entity, when set.
owner `` A single dbt owner (one row per owner). Field Filters map to this column.

No data tests defined 🧐

Not referenced by any model or exposure.

Models

No called script or script source not found.

{{ config(materialized='table', tags=['s3_inventory']) }}

-- Normalized dbt owners: one row per (entity, owner), exploded from the JSON-array
-- `owner` column on Elementary's captured dbt metadata (dbt_models, dbt_sources).
-- Keyed by dbt `unique_id` so any dashboard can join on its own entity (a file →
-- its model/source unique_id).
--
-- Mirrors dbt_entity_tags: exists so Metabase Field Filters can drive multi-select
-- "is any of" owner filtering. A Field Filter must map to a scalar column with one
-- value per row, which the `owner` array (or a comma-joined string) cannot provide
-- — hence the exploded grain here. Owners only apply to models/sources (not tests).

with models as (
    select
        unique_id,
        name,
        'model' as kind,
        schema_name,
        json_extract_string(meta, '$.s3_location') as s3_location,
        owner
    from {{ ref('dbt_models') }}
),

sources as (
    select
        unique_id,
        name,
        'source' as kind,
        schema_name,
        json_extract_string(meta, '$.s3_location') as s3_location,
        owner
    from {{ ref('dbt_sources') }}
),

entities as (
    select * from models
    union all
    select * from sources
)

select
    unique_id,
    name,
    kind,
    schema_name,
    s3_location,
    unnest(cast(owner as varchar[])) as owner
from entities
where owner is not null and owner <> '[]'