Skip to content

overrideViewLineage does not remove old view lineage when a view no longer references any table #37091

Done

Description

@hollylessthan

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.

  1. 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;
  2. Run database metadata ingestion, then database lineage ingestion (relevant settings under "Connection / ingestion config").

  3. Confirm the lineage API returns both upstream edges:

    GET /api/v1/lineage/table/{out_id}?upstreamDepth=1&downstreamDepth=0
    
    a → out
    b → out
    
  4. Redefine the view without upstream tables:

    CREATE OR REPLACE VIEW s.out AS
    SELECT 42::integer AS id;
  5. 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 returns a → out and c → out.
  • Explicitly deleting lineage with DELETE /api/v1/lineage/table/{id}/type/ViewLineage clears 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_lineage in ingestion/src/metadata/ingestion/sink/metadata_rest.py, once per lineage request. view_lineage_processor produces 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

  1. added
    bug
    on Nov 5, 2026
  2. Vamsi-klu commented on Nov 9, 2026

    @Vamsi-klu
    Contributor

    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.

  3. added a commit that references this issue on Nov 24, 2026
    5c3512e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Ingestionbugconnector:other

Type

No type

Projects

  • Status
    Done ✅
  • Status
    Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions