Area: Ingestion
Sub-Area: Lineage
Applies to: OSS + Cloud
Issue
Lineage between different platforms (for example S3 to Snowflake, or BigQuery to Looker) does not connect. The usual cause is that the dataset URN written by one source does not match the URN another source or your own code uses for the same dataset.
You Might Be Asking
- How do I create lineage between different platforms?
- Why isn't my cross-platform lineage connecting?
- How do I map platform identifiers?
Cause
Lineage connects only when both sides use the same dataset URN. Mismatches usually come from:
- Case. Snowflake lowercases dataset URNs by default (
convert_urns_to_lowercasedefaults to true). BigQuery keeps the original case by default (convert_urns_to_lowercasedefaults to false). SQLAlchemy-based sources default to false. - The S3 dataset name. The S3 source removes the URI scheme and any leading or trailing slashes from the table path. It lowercases the path if
convert_urns_to_lowercaseis set. A name written ass3://bucket/pathdoes not match it. - Recipe keys that do not exist. Recipes reject unknown keys, so a made-up key fails validation.
- Missing platform instance or BI tool connection mapping.
Solution
-
Copy the exact URN from DataHub for each dataset instead of building it by hand or changing its case. Do not uppercase Snowflake names or lowercase BigQuery names. See URN Structure.
-
For Snowflake external tables, you don't set a flag. The
table_typesoption defaults to{"BASE TABLE","EXTERNAL TABLE"}. WhileEXTERNAL TABLEis intable_types, the Snowflake source runs an external table DDL lineage stage. To turn it off, removeEXTERNAL TABLEfromtable_types.include_external_tablesis not a Snowflake key, and a recipe that sets it fails validation. See the Snowflake source for the lineage grants and config details. Ingest S3 with its own recipe, in a separate file from the Snowflake recipe. A YAML file with two top-levelsource:keys keeps only the last one. See the S3 source forpath_specsand the{table}placeholder. -
To add a cross-platform edge yourself, add it as a patch. A patch adds one upstream edge and leaves the other edges alone. Use
DatasetPatchBuilder(urn).add_upstream_lineage(upstream), or the SDK lineage client'sadd_lineage(upstream=..., downstream=...), which builds aDatasetPatchBuilderfor the downstream dataset.Warning: Do not write the whole
upstreamLineageaspect to add one edge. Do not useset_upstream_lineages. Both replace all upstream edges.On Cloud, use your tenant URL ending in
/gmsand a personal access token. For OSS, use your own GMS address.
from datahub.emitter.mce_builder import make_dataset_urn
# The S3 name has no s3:// prefix. Snowflake names are lowercase by default.
s3_urn = make_dataset_urn("s3", "my-bucket/analytics/customers")
snowflake_urn = make_dataset_urn("snowflake", "analytics_db.public.customers")
The lineage types are COPY, TRANSFORMED and VIEW. A connector with incremental_lineage set to false re-states its lineage on each run. incremental_lineage is false by default. dbt sets its default to true. See Lineage SDK tutorial and the Lineage feature guide.
If you use DatahubRestEmitter, emit the output of the patch. Call emit_mcp once for each item from patch.build(): for mcp in patch.build(): emitter.emit_mcp(mcp). The emit_mcp method takes one MetadataChangeProposalWrapper. It does not take entity_urn, aspect_name or aspect arguments. See Python emitter.
-
To use a platform instance in a URN, build it with
make_dataset_urn_with_platform_instance(platform, name, platform_instance). Use the same platform instance in the recipe that produces the other side. -
To map BI tool connections to data platforms:
- LookML:
connection_to_platform_mapis a key on thelookmlsource. Each value is an object with requiredplatformanddefault_db, and optionaldefault_schema,platform_instanceandplatform_env. Set the platform instance inside each entry. Old string values such as"platform.db"are still converted. A bare platform string is converted with a warning that resolution may fail.
- LookML:
source:
type: lookml
config:
connection_to_platform_map:
production_snowflake:
platform: snowflake
default_db: analytics_db
default_schema: public
platform_instance: prod_snowflake
- Tableau: use
lineage_overrides. It hasplatform_override_map(platform to platform) anddatabase_override_map(database to database).database_hostname_to_platform_instance_mapchanges the platform instance in generated URNs.
See the Looker and LookML source and the Tableau source.
- After the change, compare the URN each side uses with the URN DataHub shows for the dataset. They must match exactly, including case.