Area: Ingestion
Sub-Area: Lineage
Applies to: OSS + Cloud
Issue
You load lineage from a file, for example for a custom ETL tool, and the ingestion fails or the lineage looks wrong. Typical causes are a recipe that uses the wrong source key, a wrong URN, a malformed field, or a connector that rewrites the lineage you loaded.
You Might Be Asking
- Which recipe keys does the file source take?
- Is there a source made for lineage files?
- How do I build the URNs and fields for table-level and column-level lineage?
- Why did my file lineage disappear after a connector ran?
Cause
-
Deprecated or unknown recipe keys. The file source takes
path. Thefilenamekey is deprecated and logs "filename is deprecated. Use path instead." Recipe configs reject unknown keys, so a misspelled or invented key fails validation. -
File extension. The file source reads files ending in
.jsonby default. Setfile_extensionto another extension, or to*to process every file. -
Wrong object shapes. Lineage objects have fixed fields:
- An upstream has
dataset(a dataset URN) andtype.typeisCOPY,TRANSFORMEDorVIEW.auditStampis optional. - A column-level (fine-grained) entry has required
upstreamTypeanddownstreamType. It also takes optionalupstreamsanddownstreamslists of URNs,transformOperation,confidenceScore(falls back to 1.0),queryandmatchType. -
upstreamTypeisFIELD_SET,DATASETorNONE.downstreamTypeisFIELDorFIELD_SET. WithupstreamTypeFIELD_SET, the lists hold schemaField URNs. WithDATASET,upstreamsholds dataset URNs.
- An upstream has
- URN case. Snowflake dataset URNs are lowercase by default. BigQuery URNs keep their original case by default. A URN with the wrong case points to a different dataset.
-
A connector restates lineage. A source with
incremental_lineageset to false (the default for most warehouse sources, including Snowflake) restates its lineage on each run. dbt defaultsincremental_lineageto true, which emits lineage as incremental to existing lineage. If a connector and your file both write lineage for the same table, the connector's runs can change what you loaded.
Solution
-
Use
path, notfilename. In the file source config of your recipe, setpathto your lineage file. Save the recipe aslineage-recipe.yml. For Cloud, set the sinkserverto your tenant's GMS URL (https://<tenant>.acryl.io/gms) and add a personal access token astoken. See the file source page forpathandfile_extension. -
Run the recipe.
datahub ingest -c lineage-recipe.yml
-
Consider the lineage file source. The
datahub-lineage-filesource is built for lineage files. It takesfile(a path or URL, required) andpreserve_upstream(default true). Withpreserve_upstream: true, it queries DataHub for existing upstreams, keeps only the table-level upstreams, and replaces column-level lineage with the file's. Withfalse, it hard replaces upstream data. Follow the file-based lineage page for the file format and the starter recipe. -
Build URNs with the SDK.
make_dataset_urn(platform, name, env=DEFAULT_ENV)builds a dataset URN.make_schema_field_urn(parent_urn, field_path)builds a schemaField URN. The parent must start withurn:li:. For the exact case, copy the URN from DataHub instead of guessing. See URN structure. -
Add edges without restating a table's lineage. When a connector also ingests the table, add edges as patches instead of loading a whole lineage aspect from a file. The
add_upstream_lineagemethod ofDatasetPatchBuilderadds or updates one edge and leaves the others alone. For column-level edges, useadd_fine_grained_upstream_lineage(fine_grained_lineage). The SDK lineage client'sadd_lineage(*, upstream, downstream, column_lineage=False, transformation_text=None)also builds a patch for the downstream dataset. Do not useset_upstream_lineages(upstreams)for this. It writes the whole list and replaces all upstream edges. For Cloud, use your tenant's GMS URL asserver. See the SDK lineage how-to. -
If you emit a whole lineage aspect, use the right call.
emit_mcptakes oneMetadataChangeProposalWrapper, for exampleemitter.emit_mcp(MetadataChangeProposalWrapper(entityUrn=downstream_urn, aspect=upstream_lineage)). It has noentity_urn,aspect_nameoraspectkeyword arguments. Create the emitter first withDatahubRestEmitter(gms_server, token=...). A whole-aspect write has the same problem as a file: a connector withincremental_lineagefalse restates that table's lineage on its next run. Prefer the patch in step 5 for tables a connector ingests. See Python emitter.
For lineage behavior around incremental_lineage, see the lineage feature guide.
Related Documentation
- Lineage feature guide
- File source
- File-based lineage source
- SDK lineage how-to
- Python emitter
- URN structure
Tags: lineage, file-based-ingestion, json, column-lineage, etl, custom-lineage, urn-format, batch-processing