Skip to content

Fixes #38325: build Looker lineage for a view once the views it reads are parsed - #39498

Open
mayuriphad wants to merge 3 commits into
open-metadata:mainfrom
mayuriphad:fix/looker-unparsed-views
Open

mayuriphad wants to merge 3 commits into
open-metadata:mainfrom
mayuriphad:fix/looker-unparsed-views

Conversation

@mayuriphad

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #38325

A Looker view whose derived table reads ${other.SQL_TABLE_NAME} before other is parsed logs Parsing it later and never gets lineage. Changes in ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py, in add_view_lineage, _add_standalone_view_lineage and build_lineage_for_unparsed_views:

  • The waiting view was added to the dependency graph but never stored in _unparsed_views, so there was nothing to retry. _defer_view now stores its SQL, plus its LookML view and data model in _unparsed_view_targets.
  • build_lineage_for_unparsed_views() is a generator and was called without yield from, so it never ran. It is now yielded from.
  • The retry only ran after a derived-table view. In the issue's example, the referenced view base uses sql_table_name, so nothing triggered the retry. It now runs after every processed view.
  • The topological sort includes referenced views that aren't waiting (e.g. a view not seen yet). self._unparsed_views[view_name] raised KeyError for them, and the whole retry stopped with a StackTraceError. Those nodes are now skipped.
  • The retry runs while another view is being processed, so _view_data_model points at that view. Retried lineage now goes to the waiting view's own data model, with its field mapping.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • daily (derived table reading ${base.SQL_TABLE_NAME}) processed before base (sql_table_name) gets lineage from base's table to daily's data model, through explores and as a standalone view.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: ingestion/tests/unit/topology/dashboard/test_looker_issue_regressions.py (the issue's two views, parametrized for explore and standalone views). Both cases fail on main, where only base gets lineage, and pass with this change.
  • pytest tests/unit/topology/dashboard/test_look*.py: 282 passed. 5 failed in test_looker_bulk_parser_refinements.py and test_looker_lkml_parser.py, and the same 5 fail on main in my Windows environment. ruff check and ruff format --check pass on both files.

Backend integration tests

  • Not applicable (no backend API changes).

A derived table reading a view that was not parsed yet logged 'Parsing
it later' and was dropped: it was added to the dependency graph but
never stored in _unparsed_views, and build_lineage_for_unparsed_views
was called without yield from, so the retry never ran. The retry also
only followed derived-table views, and it would stop with a KeyError on
a referenced view that had not been seen yet.

Keep each waiting view's SQL, LookML view and data model, retry after
every processed view, skip graph nodes that are not waiting, and send
the retried lineage to the waiting view's own data model.

Fixes open-metadata#38325

Signed-off-by: mayuriphad <[email protected]>
@mayuriphad
mayuriphad requested a review from a team as a code owner December 2, 2026 01:38
@mayuriphad
mayuriphad requested review from akashverma0786 and a balanced review from Copilot and removed request for a team December 2, 2026 01:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

It is always a dict, and the Optional type made basedpyright reject the
assignment in _defer_view.

Signed-off-by: mayuriphad <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 14:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

"""
self._add_dependency_edge(view.name, view_references)
self._unparsed_views[view.name] = sql_query
self._unparsed_view_targets[view.name] = (view, self._view_data_model)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A view used in two models only gets lineage for one of them

This keeps one target per view name. If daily is used in models m1 and m2 and both are deferred before base is parsed, the m2 entry replaces the m1 one. Only m2_daily_view gets lineage; m1_daily_view gets none.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 009a470. _unparsed_view_targets now keeps a list of (view, data model) targets per view name, and the retry builds lineage for each one. Added test_view_waiting_in_two_models_gets_lineage_to_both_data_models, where daily waits on base in m1 and m2. Both data models get the edge.

@akashverma0786

Copy link
Copy Markdown
Collaborator

Hey @mayuriphad Thanks for the contribution,
Could you please check gitar-bot finding too.
Thanks

…t the end of the bulk stage

A view used in two models kept only the last model's target while waiting,
so the first model's data model got no lineage. Keep one target per model.

A view that resolves through a derived reference returns before its own
retry, so a view waiting on it could be left without lineage. Retry once
more after both lineage loops of the bulk stage.

Signed-off-by: mayuriphad <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 6, 2026 04:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Dec 6, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findings

Deferring and retrying Looker view lineage changes ingestion behavior; incorrect dependency resolution could omit or misattribute lineage for affected views.

Fixes Looker lineage for views whose derived table references another view that is parsed later, by storing deferred view state, yielding the retry generator, and running the retry after every processed view. Resolved the finding that the retry was skipped when a view resolved through a derived reference, so the waiting view now gets lineage in both explores and standalone views. No open issues remain.

✅ 1 closed
✅ Edge Case: Retry is skipped when a view resolves through a derived reference

📄 ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py:1582-1585 📄 ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py:1619-1620 📄 ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py:1442-1445 📄 ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py:1479-1480
In both add_view_lineage and _add_standalone_view_lineage, take a view whose sql_table_name is ${raw.SQL_TABLE_NAME}, where raw is a derived view. _resolve_view_reference returns (None, derived_sql), and _build_lineage_for_view stores the view in _parsed_views. Then if sql_table_name is None: return exits before the new if self._unparsed_views: yield from self.build_lineage_for_unparsed_views(). If that view is the last one processed, a view deferred on it never gets lineage. This is the same bug #38325 reports, just one level of indirection away.

The PR description says the retry "now runs after every processed view", but that early return breaks the claim. The most robust fix is one final build_lineage_for_unparsed_views() pass in _yield_bulk_datamodel_lineage, after both the explore loop and the standalone loop. This works because _unparsed_view_targets already holds each waiting view's data model. Then no early return inside a view handler can drop a deferred view.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Looker: a derived table referencing a view not parsed yet never gets lineage

4 participants