Area: Ingestion
Sub-Area: Lineage
Applies to: OSS + Cloud
Issue
Lineage for database views, including materialized views, is missing or does not show the base tables it depends on.
You Might Be Asking
- How does DataHub handle view lineage?
- Why isn't my view lineage showing?
- Do I need a recipe key to turn on view lineage?
Cause
Most view lineage problems come from one of these:
- A recipe copied from another source uses keys that do not exist for your source, such as
parse_view_ddlorinclude_materialized_viewson Snowflake. Recipe configs reject unknown keys, so the recipe fails validation. - A recipe still sets a key that was removed. Removed keys are dropped with a warning ("The
was removed on , please remove it from your recipe."). The recipe still runs, but the key does nothing. - The source does not have the view definition, or the definition fails to parse. Parse failures show up in the ingestion report.
- Lineage you wrote yourself is replaced or sits next to lineage that the connector writes on each run.
Solution
1. Remove keys that do not exist or were removed
- Snowflake:
include_view_lineageandinclude_view_column_lineagewere removed in December 2024. View and external table DDL lineage are always ingested when definitions are available. - BigQuery:
include_view_lineage,include_view_column_lineageandlineage_parse_view_ddlwere removed in January 2025. View and snapshot lineage are always ingested when definitions are available. -
parse_view_ddlis not a Snowflake key. Remove it. View DDL parsing needs no key.
Delete these keys from your recipe. No replacement is needed.
2. Check keys for SQLAlchemy-based sources
For SQLAlchemy-based sources such as Postgres and MySQL, include_views, include_tables, include_view_lineage and include_view_column_lineage all default to true. DataHub's SQL parser builds the view lineage. A recipe that sets them to true changes nothing. Set one to false only if you want to turn it off.
source:
type: postgres
config:
include_views: true
include_view_lineage: true
include_view_column_lineage: true
3. Use only keys your source defines
-
include_materialized_viewsis a key on the Oracle and ClickHouse sources (defaulttrue). Do not add it to a Snowflake recipe. - The Redshift source reads late-binding view columns with
pg_get_late_binding_view_cols().
See the source's config reference for the full key list: Snowflake, BigQuery, Postgres.
4. Find view parse failures
When a view definition fails to parse at the table level, the ingestion report increments num_views_failed and records the error in views_parse_failures. The view then gets no lineage, except a table-level fallback when the source supplies one. These report fields appear at any log level.
To test how DataHub parses the view SQL, run the parser from the CLI:
datahub check sql-lineage --platform snowflake --sql "<query>"
Use --sql-file <file> for a file. --platform is required. Optional flags are --platform-instance, --env, --default-db and --default-schema. The command runs online by default. It uses schemas stored in DataHub to produce column-level lineage. With --offline, or when tables are missing from DataHub, results are less accurate.
From Python, DataHubGraph.parse_sql_lineage(sql, *, platform, platform_instance=None, env=DEFAULT_ENV, default_db=None, default_schema=None, override_dialect=None) returns a SqlParsingResult. See SQL parsing.
5. Add missing view lineage by hand, as a patch
Most warehouse sources default incremental_lineage to false and re-state lineage on each run. dbt defaults it to true. Use a patch to add one edge. A patch adds or updates that edge and leaves the other edges alone. Do not write a whole lineage aspect.
from datahub.emitter.mce_builder import make_dataset_urn
from datahub.ingestion.graph.client import DataHubGraph
from datahub.ingestion.graph.config import DatahubClientConfig
from datahub.metadata.schema_classes import UpstreamClass
from datahub.specific.dataset import DatasetPatchBuilder
# Cloud: server="https://<tenant>.acryl.io/gms" with a personal access token
graph = DataHubGraph(
DatahubClientConfig(server="http://localhost:8080", token="<token>")
)
view_urn = make_dataset_urn("snowflake", "analytics_db.public.customer_summary_view")
base_urn = make_dataset_urn("snowflake", "raw_db.public.customers")
patch = DatasetPatchBuilder(view_urn).add_upstream_lineage(
UpstreamClass(dataset=base_urn, type="VIEW")
)
for mcp in patch.build():
graph.emit(mcp)
UpstreamClass takes dataset and type. type is COPY, TRANSFORMED or VIEW. The SDK lineage client also has add_lineage(*, upstream, downstream, column_lineage=False, transformation_text=None), which builds a DatasetPatchBuilder for the downstream dataset. For more steps, see the lineage SDK guide.
If you call emit_mcp yourself, pass one MetadataChangeProposalWrapper, for example emitter.emit_mcp(MetadataChangeProposalWrapper(entityUrn=view_urn, aspect=aspect)). emit_mcp has no entity_urn, aspect_name or aspect keyword arguments. For emitter setup, see Python emitter.
6. Query lineage with GraphQL
Use searchAcrossLineage(input: SearchAcrossLineageInput!), or the lineage input type LineageInput. LineageInput requires direction (LineageDirection!). It also takes start, count, separateSiblings, startTimeMillis, endTimeMillis and includeGhostEntities (default false). Dataset has no upstreamLineage or downstreamLineage fields. On Cloud, use https://<tenant>.acryl.io/api/graphql with a personal access token. See GraphQL setup and lineage API examples.