Area: Ingestion Issues
Sub-Area: dbt Ingestion / URN Management / Sibling Lineage
Applies to: OSS + Cloud
Issue
You changed convert_urns_to_lowercase in a dbt recipe, for example from false to true. Now each dbt model has two datasets: the old one with uppercase names and a new one with lowercase names. The warehouse table's sibling still points to the old uppercase dataset. The merged sibling view shows no downstream lineage, but the dbt or warehouse view on its own shows it.
You Might Be Asking
- Why do I have two dbt datasets for the same model that differ only in letter casing?
- How do I remove stale uppercase dbt URNs after changing
convert_urns_to_lowercasetotrue? - How do I fix the sibling relationship after cleaning up duplicate URNs?
- Will enabling stateful ingestion automatically remove stale dbt assets?
Cause
Changing convert_urns_to_lowercase gives every dbt model a new URN. The datasets with the old URNs stay in DataHub, and the warehouse table's sibling still points to the old dbt URN.
Solution
1. Find the duplicates
Search for the dbt model in DataHub. The stale dataset has uppercase characters in its name and an older last-synced time.
# Stale (uppercase)
urn:li:dataset:(urn:li:dataPlatform:dbt,MY_SCHEMA.RELEASE.my_model_name,PROD)
# Current (lowercase)
urn:li:dataset:(urn:li:dataPlatform:dbt,my_schema.release.my_model_name,PROD)
2. Point the siblings at the lowercase URN
Set the siblings aspect on both the lowercase dbt dataset and the warehouse table, so each points to the other.
from datahub.emitter.mcp import MetadataChangeProposalWrapper
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.metadata.schema_classes import SiblingsClass
emitter = DatahubRestEmitter(gms_server="https://<your-instance>.acryl.io/gms", token="<your-datahub-token>")
dbt_urn = "urn:li:dataset:(urn:li:dataPlatform:dbt,my_schema.release.my_model_name,PROD)"
warehouse_urn = "urn:li:dataset:(urn:li:dataPlatform:snowflake,my_schema.release.my_model_name,PROD)"
emitter.emit(MetadataChangeProposalWrapper(entityUrn=dbt_urn, aspect=SiblingsClass(siblings=[warehouse_urn], primary=True)))
emitter.emit(MetadataChangeProposalWrapper(entityUrn=warehouse_urn, aspect=SiblingsClass(siblings=[dbt_urn], primary=False)))
This replaces the siblings list on both datasets. If a dataset has other siblings, add them to its list.
Do not use datahub dataset add-sibling for this step. It adds to the existing list, so the warehouse table keeps its sibling link to the stale uppercase dataset.
3. Soft delete the stale uppercase URNs
datahub delete --urn "urn:li:dataset:(urn:li:dataPlatform:dbt,MY_SCHEMA.RELEASE.my_model_name,PROD)" --soft
A soft delete hides the dataset from search and browse. To undo it, use datahub delete undo-by-filter. On DataHub Cloud, the datahub-gc job hard deletes an entity by default once it has been soft deleted for 30 days. Until then you can undo the delete.
Do not use POST /entities?action=delete for this step. It is a permanent hard delete, and it also removes the dataset's timeseries data.
4. Check the lineage
Open the warehouse table in the default merged view. Make sure the downstream lineage shows, and that Composed of lists only the lowercase dbt dataset.
Stateful ingestion and casing changes
Stateful ingestion does not remove all stale uppercase URNs by itself:
- It removes only URNs that were in the last successful run and are missing from the current run. Uppercase URNs from runs before stateful ingestion was on are never removed. Soft delete them as in step 3.
- If stateful ingestion was on when you changed the casing, almost every URN changes. That is more than the default
fail_safe_thresholdof 75 percent, so the run skips the removal and reports a failure. Setstateful_ingestion.fail_safe_thresholdto100for one run, then set it back. - A recipe that you run with the CLI must have a top-level
pipeline_namewhen stateful ingestion is on. Ingestion that you schedule in the DataHub UI sets it for you.
The settings are in Stateful Ingestion.
Related Documentation
Tags: dbt, sibling-lineage, duplicate-urns, convert-urns-to-lowercase, stateful-ingestion, urn-casing, soft-delete