Repository navigation
Description
Connector
dbt
Feature area
Lineage
Describe the bug
My dbt project runs on one database service (warehouse) and reads source tables that are ingested under a different database service (events). I set catalogMapping so the dbt agent finds those tables in the other service.
Table lineage works. _get_table_entity_in_mapped_database looks the source up in the configured service and then in *, finds events.events.mobile_app.users, and the dbt edge events.events.mobile_app.users → warehouse.warehouse.mobile_app.users is created.
Column lineage never appears. create_dbt_query_lineage parses the model's compiled SQL with
get_lineage_by_query(..., service_names=source_elements[0], ...)where source_elements[0] is the service of the model being processed (warehouse). The parser looks up every table in the SQL in that one service only, so "events"."mobile_app"."users" is searched as warehouse.events.mobile_app.users, which doesn't exist, and no edge with column lineage is created. _map_catalogs_in_sql (#35603) rewrites the database name in the SQL but not the service, so it doesn't help when the mapped database lives in another service.
searchAcrossDatabases has the same gap: it also lets table lineage resolve an upstream under another service, and query lineage then searches only the model's service.
The line is unchanged on main (ingestion/src/metadata/ingestion/source/database/dbt/metadata.py, create_dbt_query_lineage) and in every release from 2.0.7 to 2.1.1.
To Reproduce
- Two database services:
warehouse(databasewarehouse) holds the dbt modelmobile_app.users;events(databaseevents) holds the source tablemobile_app.users. Both are Redshift. - The model's compiled SQL is
select * from "events"."mobile_app"."users". - Run dbt ingestion with
serviceName: warehouseandcatalogMapping: {events: events}(config below). - The model's lineage shows the table edge from
events.events.mobile_app.users, with no column lineage.
To narrow it down, I called the real lineage parser against a 2.0.7 server the way create_dbt_query_lineage does: get_lineage_by_query with create table "warehouse"."mobile_app"."users" as <compiled SQL>, Redshift dialect, database_name="warehouse", schema_name="mobile_app", changing only service_names:
service_names |
Result |
|---|---|
["warehouse"] (what the dbt source passes) |
no lineage |
["warehouse", "events"] |
1 edge, 7 column mappings |
["warehouse", "*"] |
1 edge, 7 column mappings |
The select * is expanded from the source table's columns as expected; the service list is the only thing in the way.
Expected behavior
Query lineage finds the source table in the service where table lineage found it, and the model gets column lineage from events.events.mobile_app.users, the same as when the model and its source are in one service.
Connection / ingestion config
source:
type: dbt
serviceName: warehouse
sourceConfig:
config:
type: DBT
dbtConfigSource:
dbtConfigType: local
dbtManifestFilePath: /app/target/manifest.json
dbtCatalogFilePath: /app/target/catalog.json
dbtRunResultsFilePath: /app/target/run_results.json
catalogMapping:
events: eventsLogs
No response
OS
No response
Python version
3.12.16
OpenMetadata version
2.0.7 (the code is the same on main)
OpenMetadata Ingestion package version
openmetadata-ingestion[dbt]==2.0.7.2
Additional context
Follows #34633 and #35603. #35603 covered a mapped catalog whose database is in the same service as the model; this is the case where it is in another service. I'll open a PR with a fix and a test that links here.
Pre-submission checklist
- I searched for duplicate issues.
- I removed credentials, hostnames, emails, and other sensitive data from logs and config.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity