Repository navigation
Fixes #38334: MicroStrategy column lineage for schema cube metrics - #38335
Conversation
A metric is linked to the columns of the SQL projection named after it, else through the metrics and facts its definition is built from.
❌ 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 |
…and load on Python 3.11 A metric the definition references now matches an alias only when no other object of the dataset shares its name, as the metric's own name already did. The ParsedCube alias default moves to a factory, since Python 3.11 refuses an unhashable dataclass default.
…ct owns that name A metric a definition references, but the dataset does not hold, could take the alias of a dataset object whose name normalizes the same. Aliases are now matched by object id: an alias is a metric's only when no other object of the dataset has that name.
A metric can set a column alias that the SQL generator names its projection after in place of its name, so a display name can match another metric's projection. Each metric's alias now comes from its definition, every dataset object claims the name it is projected under before any metric is matched, and referenced metrics are matched on their own alias. Without modeling privileges the name stands in for the alias.
A metric whose definition fails to read dropped out of the alias claims, so another metric sharing its name could take its projection. It now claims its name, blocking that match without getting a column edge itself.
| def _metric_sql_name(self, project_id: str, metric: MstrAvailableObject) -> str | None: | ||
| """ | ||
| The name the SQL gives a schema metric's projection, from its definition. Without modeling | ||
| privileges no column alias can be read, so the metric's name stands in for it; a metric that | ||
| cannot be read otherwise, such as one derived in a dossier, is projected under no name. | ||
| """ | ||
| sql_name = self.client.get_metric_sql_name(project_id, metric.id, metric.name or "") | ||
| if sql_name is None and self.client.modeling_denied: | ||
| return metric.name | ||
| return sql_name |
There was a problem hiding this comment.
Could we leave metric column lineage unresolved when a 403 prevents establishing alias ownership?
There was a problem hiding this comment.
Agreed, done. Without Architect read, metrics now get no column lineage instead of a guess by name.
UI browser testsRan: all test files (no impact map from main yet) Result: ✅ 1070 passed · 154 skipped |
… be read Without modeling privileges a metric's column alias is unknown, so matching its name could take a projection another metric's alias names. Metrics now get no column edge then; they still claim their names, so no other metric takes those projections.
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findingsAdds MicroStrategy metric and fact resolution to column lineage, so incorrect alias or definition matching could misstate warehouse dependencies in the catalog. Adds column-level lineage for schema-based MicroStrategy cube metrics, linking them to the warehouse columns their SQL projection or definition reads. Referenced-metric alias lookup now respects the ambiguity guard, so a shared alias no longer produces a wrong link. No open issues remain. ✅ 1 closed✅ Edge Case: Referenced-metric alias lookup skips the ambiguity guard
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 #38334
Metrics of schema-based MicroStrategy cubes now get column-level lineage. Until now they got table-level lineage only.
Revenue RankbecomesREVENUERANK. The metric is linked to the warehouse columns that projection reads. The column alias is read from the metric's definition, so metric column lineage needs Architect read; without it, metrics get no column edge rather than a guessed one.Revenuebut aliasedNETAMOUNTnever takes another metric'sREVENUE. Referenced metrics are matched on their own alias too, even ones the dataset does not hold. A metric that cannot be read still claims its name, so it blocks that projection without getting a link.WJXBFSnaliases are never mapped by position.ApplySimpleover two columns links both.Type of change:
High-level design:
Recorded in a v8 amendment to ADR:2026-11-05-microstrategy-charts-are-named-by-dossier-and-the-search-is-paged.
Tests:
Unit tests
ingestion/tests/unit/topology/dashboard/test_microstrategy.py, 125 pass:Manual testing performed
order_items.quantityon the cube and on the report built on it.columnNameAlias(absent when unset), and the client reads it from the definition it already fetches. The cube SQL using it is per the MicroStrategy docs, not re-run.Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code
The PR still needs the existing fix for unreadable metrics allowing wrong column links before merging.
Findings
Summary
Adds column-level lineage for schema-cube metrics in MicroStrategy.
Khairajani documents the accepted limits: name matching without Architect access can be wrong, and alias claims cannot cover metrics outside the dataset that its definitions never reach.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Schema metric] --> B[Read metric definition] B --> C{SQL alias has one owner?} C -->|Yes| D[Use columns read by that alias] C -->|No| E[Follow referenced metrics and facts] E --> F[Match fact columns against cube SQL] D --> G[Add column lineage] F --> GReviews (9) · Last reviewed commit: "MicroStrategy: match a metric's SQL proj..." · Reviewed by Greptile