Repository navigation
Description
Connector
PostgreSQL (also MySQL, MariaDB, ClickHouse, Trino, SQL Server)
Feature area
Lineage
Describe the bug
With overrideViewLineage: true, lineage ingestion correctly replaces a view's upstream edges when the view changes from one nonempty set of tables to another.
However, when the view is redefined so it references no upstream tables, its previous lineage edges remain. Ingestion completes successfully, but the lineage API still returns the old upstream dependencies.
Ingesting the same zero-dependency view into a fresh schema produces no upstream edges.
To Reproduce
PostgreSQL 16.
-
Create the tables and view:
CREATE SCHEMA s; CREATE TABLE s.a (id int); CREATE TABLE s.b (id int); CREATE TABLE s.c (id int); CREATE VIEW s.out AS SELECT id FROM s.a UNION ALL SELECT id FROM s.b;
-
Run database metadata ingestion, then database lineage ingestion (relevant settings under "Connection / ingestion config").
-
Confirm the lineage API returns both upstream edges:
GET /api/v1/lineage/table/{out_id}?upstreamDepth=1&downstreamDepth=0 a → out b → out -
Redefine the view without upstream tables:
CREATE OR REPLACE VIEW s.out AS SELECT 42::integer AS id;
-
Run both ingestion workflows again and query the lineage API.
Actual: the API still returns a → out and b → out.
Expected behavior
With overrideViewLineage: true, re-ingesting the updated view should remove its previous ViewLineage upstream edges, leaving no upstream dependencies.
Connection / ingestion config
# Metadata ingestion (postgres). Relevant fields only, not complete workflows.
sourceConfig:
config:
type: DatabaseMetadata
includeTables: true
includeViews: true
markDeletedTables: false
schemaFilterPattern:
includes: ["^s$"]
---
# Lineage ingestion (postgres-lineage)
sourceConfig:
config:
type: DatabaseLineage
processViewLineage: true
processQueryLineage: false
incrementalLineageProcessing: false
overrideViewLineage: true
schemaFilterPattern:
includes: ["^s$"]
These are the relevant configuration fields, not complete workflow definitions.
Logs
Ingestion completes successfully with no errors or warnings.OS
Ubuntu 24.04 (Docker)
Python version
3.12
OpenMetadata version
2.0.7
OpenMetadata Ingestion package version
openmetadata-ingestion==2.0.7.0
Additional context
- Replacing the dependencies
{a, b}with{a, c}(CREATE OR REPLACE VIEW s.out AS SELECT id FROM s.a UNION ALL SELECT id FROM s.c;) works correctly: the API returnsa → outandc → out. - Explicitly deleting lineage with
DELETE /api/v1/lineage/table/{id}/type/ViewLineageclears the old edges. - The issue therefore appears specific to a view with an empty upstream dependency set.
- Possible cause: the override delete appears to run only inside
write_override_lineageiningestion/src/metadata/ingestion/sink/metadata_rest.py, once per lineage request.view_lineage_processorproduces one request per parsed upstream edge, so a view with no upstreams produces no request and the delete never runs. - The same behavior occurs with MySQL, MariaDB, ClickHouse, Trino and SQL Server views on 2.0.7, so it does not appear to be specific to the PostgreSQL connector.
- Related: Support Automatic Cleanup of Outdated Lineage Entries #22445 (automatic cleanup of outdated lineage). This issue concerns a narrower case: with
overrideViewLineage: true, nonempty view lineage is replaced correctly, but previously stored edges are not removed when the updated view has no upstream dependencies.
Pre-submission checklist
- I searched for duplicate issues.
- I removed credentials, hostnames, emails, and other sensitive data from logs and config.
Activity
Vamsi-klu commentedon Nov 9, 2026
I'm working on this and will open a PR shortly. The fix emits an explicit ViewLineage delete for a view whose definition a grammar parser (SqlGlot/SqlFluff) read and found reading no table, under overrideViewLineage only. Parse failures, missing definitions and upstream tables that are not ingested yet keep the stored lineage.
Fixes open-metadata#37091: Clear view lineage when a view no longer r…