Area: Ingestion Issues
Sub-Area: Sibling Entity Configuration
Applies to: OSS + Cloud
Issue
You ingest dbt and a warehouse (Snowflake, Databricks Unity Catalog, or another platform) into DataHub. A dbt model and its warehouse table show up as two separate entities. They should be one combined entity, with a Composed of section in the sidebar that lists both.
You Might Be Asking
- Why do I see two entries for the same table in DataHub?
- How do I make a dbt model and its warehouse table show as one entity?
- Should I set
convert_urns_to_lowercase: falsein my dbt recipe? - I fixed my recipes and re-ran ingestion, but the dbt model and the table are still separate. Why?
Cause
The dbt source builds a URN for the warehouse table of each model from its own recipe: target_platform, target_platform_instance, env, convert_urns_to_lowercase, and the model's <database>.<schema>.<table> name. It writes lineage onto that URN. DataHub then links the dbt model and that warehouse URN as siblings.
If that URN is not exactly the URN your warehouse connector created, dbt links to a warehouse entity that no warehouse ingestion created. The real warehouse table stays on its own. Any difference splits them: letter case, platform instance, env, or a name prefix.
The order you run the two ingestions in does not matter. DataHub links the siblings either way.
Solution
1. Compare the two URNs
Open the dbt model and copy the URN of its warehouse sibling. Open the table that your warehouse connector ingested and copy its URN. Find the part that differs.
You can also read the sibling links with the CLI:
datahub get --urn "<dbt-model-urn>" -a siblings
2. Make the dbt recipe build the same URN
Snowflake + dbt:
- Both sources set
convert_urns_to_lowercase: trueby default. Keep the same value in both recipes. Don't set it tofalsein the dbt recipe alone. The dbt URNs then keep their original case and no longer match the lowercase Snowflake URNs. The Snowflake source logs a warning when the option isfalse: "Please useconvert_urns_to_lowercase: True, otherwise lineage to other sources may not work correctly." - If the Snowflake recipe sets
platform_instance, settarget_platform_instancein the dbt recipe to the same value. - Set the same
envin both recipes. Both default toPROD.
Databricks Unity Catalog + dbt:
# dbt recipe
source:
type: dbt
config:
target_platform: databricks
target_platform_instance: "<same value as platform_instance in the Unity Catalog recipe>"
env: PROD
# Unity Catalog recipe
source:
type: unity-catalog
config:
platform_instance: "<your-instance-name>"
env: PROD
- Unity Catalog names each table
<catalog>.<schema>.<table>. The first part of the dbt name (the database) must be the catalog name. - Leave
include_metastoreunset orfalse. When it istrue, Unity Catalog adds the metastore id to every table name and uses the workspace name as the platform instance, so dbt URNs never match. The option is deprecated.
The dbt platform_instance setting only scopes the dbt URNs. It does not need to match the warehouse. See Working With Platform Instances and the dbt source config details.
Caution: these settings are part of every URN. If you change convert_urns_to_lowercase, env or platform_instance in a recipe, every dataset from that recipe gets a new URN. Descriptions, tags, owners and glossary terms added in the DataHub UI stay on the old datasets. To clean up after a casing change, follow Fixing Duplicate dbt URNs Caused by URN Casing Changes Breaking Sibling Lineage.
3. Re-run the dbt ingestion and check the result
Re-run the dbt ingestion. Open the warehouse table. The sidebar shows Composed of with both the dbt model and the table.
4. If the dbt model still links to the wrong entity
DataHub adds a sibling link only when neither dataset has one yet. If the dbt model was linked to the wrong warehouse URN before your fix, and its own URN did not change, it keeps the old link and DataHub does not link it to the real table. This happens when you only fixed target_platform_instance, for example.
Fix the links with a patch. This removes only the stale sibling and adds the correct one, and leaves the rest of the aspect alone. Patching siblings needs DataHub Cloud or an OSS server on v1.3.0 or later.
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.specific.dataset import DatasetPatchBuilder
emitter = DatahubRestEmitter(gms_server="https://<your-instance>.acryl.io/gms", token="<your-datahub-token>")
dbt_urn = "urn:li:dataset:(urn:li:dataPlatform:dbt,analytics.prod.orders,PROD)"
stale_urn = "urn:li:dataset:(urn:li:dataPlatform:snowflake,analytics.prod.orders,PROD)"
warehouse_urn = "urn:li:dataset:(urn:li:dataPlatform:snowflake,snowflake_prod.analytics.prod.orders,PROD)"
for mcp in DatasetPatchBuilder(dbt_urn).remove_sibling(stale_urn).add_sibling(warehouse_urn, primary=True).build():
emitter.emit(mcp)
for mcp in DatasetPatchBuilder(warehouse_urn).add_sibling(dbt_urn).build():
emitter.emit(mcp)
Replace the three URNs with your own: the dbt model, the wrong warehouse URN it points to now, and the table your warehouse connector ingested.
5. Remove the leftover entities
The wrong warehouse URNs that dbt wrote earlier stay in DataHub. Delete them one by one. Preview first. A dry run lists what it would delete and deletes nothing:
datahub delete --urn "<stale-urn>" --dry-run
datahub delete --urn "<stale-urn>"
The command soft deletes by default, and you can undo it with datahub delete undo-by-filter. Don't run datahub delete --platform <platform> for this. It deletes every entity on that platform, including the tables you want to keep. See Removing Metadata from DataHub.
Related Documentation
- dbt source
- Snowflake source
- Databricks source (Unity Catalog)
- Working With Platform Instances
- Removing Metadata from DataHub
- dbt Core platform_instance and target_platform_instance in Multi-Account Environments
Tags: dbt, snowflake, databricks, unity-catalog, sibling-entities, duplicate-assets, ingestion-configuration, platform-instance, urn-alignment, convert-urns-to-lowercase