Repository navigation
feat(ingestion): ingest LookML measures as first-class Metric entities - #33338
Conversation
❌ 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 |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
493152d to
276a3ef
Compare
| yield Either(right=data_model_request) | ||
| self.register_record_datamodel(datamodel_request=data_model_request) | ||
|
|
||
| self._collect_view_measures(view, explore.project_name) |
There was a problem hiding this comment.
Imported measures get duplicate identities
Project parsers aggregate all configured repositories, so an explore in project B can load a view imported from project A. The API candidate uses the field's project A, while this call assigns project B to the LookML candidate. Their identities no longer merge, and the same measure becomes two globally named metrics. The standalone collection call similarly assigns every discovered view to first_project. Retain the view's defining repository/project and use that provenance consistently in both collection paths.
| assets: list[EntityReference] = [] | ||
| seen: set[str] = set() | ||
| data_models = [ | ||
| self._views_cache.get(candidate.view), |
There was a problem hiding this comment.
Metric relationships cross project boundaries
When two projects define orders.count, API candidates correctly produce distinct metric identities, but both later read the same _views_cache["orders"], _metric_views["orders"], and source-reference bucket. With repository ingestion enabled, a metric can therefore receive another project's defining data model and upstream table relationships. Scope these lookups by project and view. The existing view caches may share this limitation, but using them for the new project-scoped metrics introduces incorrect relationships on those metrics.
A LookML measure carries an aggregation, an optional SQL body, filters and a
value format; flattening it into a Column on the view's data model loses all of
that. Emit each measure as a Metric instead, behind a new `includeMetrics` flag
on the dashboard metadata pipeline (default false, because the Metric namespace
is global).
Measures are collected from both the Looker API (`explore.fields.measures`,
which needs no git credentials) and the LookML files, then merged on the
identity `(project, defining view, measure)` with LookML winning. That merge is
what collapses a measure joined into many explores, or inherited through
`extends`, into a single entity, and what makes repeated runs idempotent.
Emission happens at the end of the bulk data-model stage, after the existing
Barrier, so `assets` can reference resolved data models without extra lookups.
Lineage (table -> metric with column lineage, and metric -> metric for
`${measure}` references) goes out as OMetaFQNLineageRequest, so the server
resolves both ends by FQN and no metric has to be read back for its id.
Naming: a Metric's FQN is assigned verbatim from its name, so names must be
globally unique. The service-prefix + digest scheme is extracted from the
Snowflake semantic-view connector into metadata/utils/metric_naming.py and
shared; identical inputs still produce identical names.
Incidental, in code this change already touches:
- add `LookMlView.dimension_groups`. `_extract_column_lineage` already iterated
"dimension_groups" via getattr, which always returned [] because the field did
not exist, so dimension-group column lineage had never run.
- narrow `_added_lineage` from `dict | None` (it is never None) and widen
`_process_and_validate_column_lineage`'s parameter to match its call sites.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…rder Three fixes to the LookML measures -> Metric path, found reviewing the feature commit and each verified against a live Looker run (64/64 measures landed, 0 errors, where the first run landed 57/64). relatedMetrics ordering. The server resolves relatedMetrics FQNs when the metric is created, but metrics were emitted in _metric_candidates insertion order -- for explore-reachable views that is the Looker API's alphabetical field order, so a derived measure whose parent sorts after it was created first and 404'd. Exactly the 7 measures carrying relatedMetrics on explore-reachable views failed; measures on LookML-only views survived only because declaration order happened to put parents first. order_parents_first() walks measure_references in DFS post-order so a measure follows everything it references, and the emitted set filters references that ordering cannot satisfy -- a reference cycle, which LookML rejects but nothing here can rely on. Project ordering. The projects backing the parsers were collected into a set, whose iteration order changes between processes because string hashing is randomised. yield_standalone_datamodels takes the first of them, and that project is part of the hashed Metric name, so every standalone view's measures would get a new name -- and a new entity, since nothing mark-deletes metrics -- on each run. Collect them in model order instead, which also pairs the project with the _all_lookml_models[0] name the same method already uses. Dimension groups as columns. get_model_fields did not return them for a LookMlView, so a parsed view data model dropped every time dimension, and the column lineage _extract_column_lineage builds for a dimension group was discarded because _get_data_model_column_fqn found no column to point at. The explore side already gets them, expanded per timeframe by the API.
…ric path Column lineage to a metric. The server accepts exactly one column endpoint on a Metric -- the metric's own FQN (LineageRepository.getChildrenNames, case METRIC), added by #33168 -- because a Metric has measures, not columns. We addressed the measure as `<metric>.measure.<name>`, so validateLineageDetails dropped every entry and the request came back 200 having stored nothing: all 63 table->metric edges of the live run landed with `columns: []`. Target the metric itself, and carry every source column as `fromColumns` of that one entry rather than repeating the same target once per column. Currencies. `gbp` and `eur` value formats were mapped to DOLLARS, which asserts something false about the data. DOLLARS is the enum's only currency, so those now map to OTHER with the currency preserved in `customUnitOfMeasurement`. Hidden measures. `LookMlField.hidden` was parsed and never read, so hidden measures -- intermediates a visible measure is built from, which Looker itself will not show -- each took a permanent slot in the global Metric namespace this feature is gated to protect. Skipped in both collection paths, handling LookML's yes/no string and the API's boolean. Partial LookML overrides. The parser reads view files verbatim and never expands `extends`, so a child view overriding only a measure's label parses to a measure with no type, no SQL and no filters -- and replaced the API-resolved candidate wholesale, turning a sum into an untyped metric with no expression. LookML now wins field by field and backfills the rest from the API, which has already applied inheritance and refinements. Aliased joins. One view joined twice reported `billing.status` and `shipping.status`, both appended as `status`, so the metric carried the same dimension once per join alias. Deduplicated by the name they collapse to. Bounded source-table cache. The per-view table memo held whole Table entities in an unbounded dict; now an LRUCache of 512 views, caching misses as well as hits. includeMetrics without includeDataModels. Measures are discovered from the explores and views the data-model stage walks, so the combination can only ever ingest zero metrics. Warn at construction and say so in the schema description, instead of a run that reports success and writes nothing.
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
… parsers `basedpyright` on 3.10 rejected `self._project_parsers[project_name] = parser`: `LookmlModel.project_name` is optional, so `dict.fromkeys(...)` produced `str | None` keys. The set comprehension it replaced carried an explicit `set[str]` annotation that papered over the same optionality. A model with no project name has no repository to parse, so it is filtered out rather than keyed under None -- which also means `yield_standalone_datamodels` can no longer take a None "first project".
| self._metric_views: dict[str, LookMlView] = {} | ||
| # (source table name, db service prefix) pairs already resolved for a view by the | ||
| # lineage pass. Recorded rather than re-derived so metric lineage reuses the render | ||
| # and constant-resolution the view lineage already did. | ||
| self._view_source_refs: dict[str, list[tuple[str, str]]] = {} |
There was a problem hiding this comment.
The new _metric_views and _view_source_refs dictionaries retain entries for every measure-bearing view for the entire ingestion run. The related candidate and explore dictionaries also grow with the catalog. This violates the repository directive that every cache must have an explicit size cap, so the requirement must be satisfied before merging. Use bounded storage or release each view's state after its metrics are emitted.
Context Used: CLAUDE.md (source)
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 2 closed / 2 findings🟡 Medium risk · Opt-in LookML measure ingestion adds Metric entities and lineage relationships. Adds opt-in LookML measure ingestion as first-class Metric entities with deterministic naming, deduplication across API and file sources, metric-to-metric lineage for derived measures, and table-to-column lineage. Resolved dead-code removal of the ✅ 2 closed✅ Quality: New
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|



Describe your changes:
Fixes open-metadata/openmetadata-collate#5990
I taught the Looker connector to emit LookML measures as
Metricentities instead of only flattening them intoColumns on the view's data model, because a measure carries an aggregation, an optional SQL body, filters and a value format that a column cannot represent. Measures are collected from both the Looker API and the LookML files and merged on identity, so a measure joined into many explores is one entity and repeated runs are idempotent. It is gated behind a newincludeMetricsflag, default false, because theMetricnamespace is global.Type of change:
High-level design:
Why a flag, defaulted off.
MetricRepository.setFullyQualifiedNameassigns the FQN verbatim from the name — aMetrichas no service segment, so the namespace is global. A large Looker instance holds thousands of measures, so this is explicit opt-in viaincludeMetricsondashboardServiceMetadataPipeline.json.Two measure sources, merged on identity. The Looker API (
explore.fields.measures) works on every deployment with no git credentials; the LookML files are the only source for views no explore references, and the only place the exact filter syntax survives. Both feed one dict keyed by(project, defining view, measure), LookML winning.original_view(not the join alias) is the defining view. That merge is what satisfies the issue's dedup/inheritance requirement: a measure joined into twelve explores, or inherited throughextends, collapses to one entity.Naming. Because the FQN is the name, names must be globally unique:
<service-prefix>-<sha256(service, project, view, measure)>, with the readable name indisplayName. The prefix/digest helper is extracted fromsnowflake/semantic_view_metrics.pyintometadata/utils/metric_naming.pyand shared — a pure move, identical inputs still produce identical names (Snowflake's 30 existing tests pass unchanged). The digest is what makes repeated ingestion idempotent.Where it runs — no topology change. The
bulk_data_modelstage has nocontext, sosink_requestforwards whatever the processor yields; Looker already exploits this forAddLineageRequestandBarrier. Metrics are emitted at the end of_yield_bulk_datamodel_lineage, after the existing Barrier, soassetsreferences resolved data models with zero extra API calls.Lineage. Both edges use
OMetaFQNLineageRequest, so the server resolves each end by FQN — no metric read-back, no id plumbing, no second Barrier. Table→Metric carries column lineage onto<metric>.measure.<name>, resolving${TABLE}.coltransitively through other fields; Metric→Metric follows${other_measure}.Alternatives rejected. Synthesising
COUNT(*)for atype: countmeasure (would put SQL in the entity that Looker never wrote; the aggregation is preserved losslessly on the measure child instead). Translating Looker filter conditions into SQL predicates (>10,-NULL,30 daysare filter expressions, not predicates — stored as LookML so they round-trip). Removing measures fromDashboardDataModel.columns(breaking for existing data models and column lineage).Known limitation, called out deliberately. There is no stale-metric cleanup:
Metrichas no service field, so nothing scopes a delete sweep, and a renamed measure creates a newMetricand leaves the old one. Neither dbt nor Snowflake cleans up either.test_renaming_a_measure_produces_a_new_namepins this so it stays a decision rather than an accident.Backward compatibility. Additive.
includeMetricsdefaults tofalse, so no existing pipeline changes behaviour.Tests:
Use cases covered
Metric, with its SQL, aggregation, filters, dimensions and defining asset${total_revenue} / 2) getsrelatedMetrics, a metric→metric edge, and column lineage resolved transitively to the source columnincludeMetrics(the default) ingests exactly as before — zero metrics, zero metric lineageUnit tests
ingestion/tests/unit/topology/dashboard/test_looker_measures.py(48 tests, LookML→Metric mapping),ingestion/tests/unit/topology/dashboard/test_looker_metric_stage.py(15 tests, the real bulk data-model stage driven the way the workflow drives it)test_looker_issue_regressions.py,test_snowflake_semantic_view_metrics.py(fixture/import only)looker/measures.py, 100% onutils/metric_naming.py(92% combined), viapytest --cov. Themetadata.pywiring is exercised end-to-end bytest_looker_metric_stage.py.740 passedacrosstests/unit/topology/dashboard+ the Snowflake semantic-view metric tests.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
make generate(regenerated Pydantic models; confirmedincludeMetrics: bool | None = False)make py_format_check— clean (ruff lint, the new-f-string-logging suppressions gate, and format)basedpyright --baselinemode=discard— 0 errors on all five new/changed modulespytest tests/unit/topology/dashboard tests/unit/topology/database/test_snowflake_semantic_view_metrics.py— 740 passedNot yet done, and the reviewer should know: I have not run this against a live Looker instance. The issue's definition of done asks for a real ingestion/readback proving round-trip and idempotency; that needs credentials I don't have. The intended check is to run the workflow twice with
includeMetrics: trueand confirm the metric count is unchanged on the second run, thatGET /v1/metrics/name/<name>?fields=assets,dimensions,measures,filtersreturns the mapped values, and that the table→metric edge appears in/v1/lineage.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>— the tracking issue is in the Collate repo, so a bare#Nin the title would autolink to an unrelated OSS issue. Linked cross-repo in the body instead.Fixes ...above.includeMetricsis a new optional boolean with afalsedefault on an ingestion pipeline config, so existing stored configs deserialize unchanged.New feature
openmetadata-docs, soincludeMetricsneeds a follow-up there. The in-repo example workflow (ingestion/src/metadata/examples/workflows/looker.yaml) is updated.Note for reviewers
The generated UI TypeScript types are included — the
github-actionsbot pushed them to this branch (Update generated TypeScript types and dereferenced schemas), and that commit was preserved through a rebase onto currentmain. A second bot commit auto-refreshing.github/playwright/impact-map.generated.jsonwas dropped during that rebase:mainhad already absorbed all 13 of its additions and has since removed an entry the stale refresh still carried, so replaying it would have revertedmain. This PR touches no Playwright specs or UI source, so it should not drift the map at all.One pre-existing limitation carries over:
_metric_viewsis keyed by view name, matching the existing_views_cacheand_parsed_views. In a multi-project instance where two projects declare a same-named view, metric lineage could read the wrong view's SQL. The metrics themselves are unaffected — their identity includes the project. Re-keying all three is its own change.Incidental fixes
Both in code this change already touches:
LookMlView.dimension_groupsdid not exist._extract_column_lineagehas always iterated"dimension_groups"viagetattr, which therefore always returned[]— dimension-group column lineage has never worked. Adding the field fixes that and gives metrics their time dimensions._added_lineagewas annotateddict | Nonebut is assigned a dict in__init__and never set toNone; theOptionalmade every use of it a type error. Narrowed, and_process_and_validate_column_lineage's parameter widened to match what both call sites already pass.🤖 Generated with Claude Code
The PR is not yet safe to merge because imported measures can still receive duplicate identities and same-named views across projects can still attach incorrect assets and source lineage; the explicit bounded-cache requirement must also be satisfied.
Findings
Summary
This PR adds opt-in ingestion of LookML measures as globally named first-class Metric entities, including dimensions, filters, relationships, assets, and table/column lineage. It also shares deterministic metric naming with Snowflake semantic-view ingestion and adds the generated configuration contracts.
includeMetrics, defaulting to false, across the ingestion schema and generated UI contracts.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR API[Looker explore API] --> Merge[Merge by project, view, measure] LookML[LookML repositories] --> Merge Merge --> Order[Order parent metrics first] Order --> Metric[Create Metric entities] Models[Resolved dashboard data models] --> Metric Metric --> Relations[Metric-to-metric lineage] Views[LookML view SQL] --> Columns[Resolve source columns] Tables[Resolved source tables] --> Columns Columns --> TableMetric[Table-to-metric lineage]Reviews (6) · Last reviewed commit: "fix(ingestion): skip Looker models with ..."