Repository navigation
Fixes #38325: build Looker lineage for a view once the views it reads are parsed - #39498
mayuriphad wants to merge 3 commits into
Conversation
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]>
❌ PR checklist incompleteThis 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 |
It is always a dict, and the Optional type made basedpyright reject the assignment in _defer_view. Signed-off-by: mayuriphad <[email protected]>
| """ | ||
| 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Hey @mayuriphad Thanks for the contribution, |
…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]>
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findingsDeferring 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
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #38325
A Looker view whose derived table reads
${other.SQL_TABLE_NAME}beforeotheris parsed logsParsing it laterand never gets lineage. Changes iningestion/src/metadata/ingestion/source/dashboard/looker/metadata.py, inadd_view_lineage,_add_standalone_view_lineageandbuild_lineage_for_unparsed_views:_unparsed_views, so there was nothing to retry._defer_viewnow 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 withoutyield from, so it never ran. It is now yielded from.baseusessql_table_name, so nothing triggered the retry. It now runs after every processed view.self._unparsed_views[view_name]raisedKeyErrorfor them, and the whole retry stopped with aStackTraceError. Those nodes are now skipped._view_data_modelpoints at that view. Retried lineage now goes to the waiting view's own data model, with its field mapping.Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
daily(derived table reading${base.SQL_TABLE_NAME}) processed beforebase(sql_table_name) gets lineage frombase's table todaily's data model, through explores and as a standalone view.Unit tests
ingestion/tests/unit/topology/dashboard/test_looker_issue_regressions.py(the issue's two views, parametrized for explore and standalone views). Both cases fail onmain, where onlybasegets lineage, and pass with this change.pytest tests/unit/topology/dashboard/test_look*.py: 282 passed. 5 failed intest_looker_bulk_parser_refinements.pyandtest_looker_lkml_parser.py, and the same 5 fail onmainin my Windows environment.ruff checkandruff format --checkpass on both files.Backend integration tests