Repository navigation
Fixes #37803: MicroStrategy column-level lineage from cube SQL to data models - #37804
Conversation
- Tell Report Services documents, templates and themes from dossiers by viewMedia (the rule MicroStrategy's mstrio-py SDK uses) and skip them before reading a definition the dossier API cannot serve. - Parse each cube's SQL once per cube and dialect instead of once per dbServicePrefixes entry and dossier; skip a prefix whose database does not match the table's qualifier. - Give repeated data model column names a suffix, and drop a repeated object. - Say when a dataset is a report rather than a cube.
A dataset can list its objects in another order on a later run; suffixes given in listing order would then move a column name to another object.
Data model columns are matched on the warehouse columns each projection of the cube SQL reads, not on MicroStrategy's generated aliases: schema attributes through their form expressions (modeling API), Data Import objects through the names the import derives from columns. Metrics of schema cubes get no column edge.
Two tables sharing a name in different schemas or projects could be linked to each other's columns. Forms name their physical table as the SQL does (table prefix, else namespace), a 403 alone means missing privileges, and a column parse failure keeps the table list.
❌ 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 |
…column The lineage view draws no edge to a nested data model column, so pairs that targeted an attribute form (Order.ID) were stored but never shown.
| if not target: | ||
| return | ||
| if data_import: | ||
| columns = {column for _, column in reads if normalized(column) == normalized(available_object.name)} |
There was a problem hiding this comment.
Could you check whether normalization can link unrelated columns?
For example, if a Data Import cube reads both ab and a_b, would a target named ab receive lineage from both?
Distinct Chinese column names also appear to normalize to an empty string. Could we cover these cases with a regression test and skip ambiguous matches?
There was a problem hiding this comment.
Thanks, it could. Fixed in 8d87cc5: an object takes the column of the same name first, else the one column whose normalized name matches. ab vs a_b and distinct Chinese names are covered by regression tests, and ambiguous matches are skipped.
| only_table = next(iter(tables.values())) if len(set(tables.values())) == 1 else None | ||
| columns = set() | ||
| for projection in select.expressions: | ||
| for column in projection.find_all(exp.Column): |
There was a problem hiding this comment.
Could you check alias resolution when a nested SELECT reuses an outer alias?
SELECT a.id,
(SELECT MAX(a.amount) FROM my_schema.refunds a) AS amount
FROM my_schema.orders a
Would this traversal resolve the inner a.amount against the outer orders table as well, potentially adding an incorrect orders.amount lineage edge? Could we add a regression test to ensure each column resolves within its SELECT scope?
There was a problem hiding this comment.
It did resolve against the outer table. Fixed in 8d87cc5: each column now resolves within its own SELECT, with your example as a regression test.
Data Import objects match the column of the same name, else one unique normalized match that keeps letters of every script; nested queries resolve columns against their own aliases; comment-led passes are read; a refused table read stops modeling calls like a refused attribute read.
The dialect and database-name caches are now LRUs capped at CACHE_SIZE, like the connector's other caches, and database names are read with model_str.
A repeated comment group in a regex backtracked exponentially on an unclosed /* (CodeQL). Comments are now skipped by a linear scan, and passes are split on blank lines, then rejoined where no statement starts.
…ed columns Passes split on a blank line before a statement, never inside a comment or quoted text; an unclosed comment ends the scan without swallowing the pass before it. A correlated column resolves against enclosing queries when its own query has no such alias. An object listed twice in a dataset counts once for name matching.
…t escapes An alias a query defines as a derived table ends the lookup there, so it never resolves to a same-named outer table. Quoted text in the pass split honours backslash escapes in the dialects sqlglot reads them in, and its end is found by a forward scan, so an unclosed string stays linear.
| if isinstance(source, exp.Table): | ||
| sources[(source.alias_or_name or source.name).lower()] = table_name_of(source) |
There was a problem hiding this comment.
Could you check whether a CTE sharing a physical table’s name could produce an incorrect column match here? For example, could c.id below be attributed to sales.my_table.id, even though it comes from a constant?
WITH my_table AS (SELECT 1 AS id)
SELECT c.id FROM my_table c CROSS JOIN sales.my_table t
| # A column of a nested query is read with that query, against its own aliases first. | ||
| if column.find_ancestor(exp.Select) is not select: | ||
| continue | ||
| table = _resolve(select, column.table.lower()) if column.table else only_table |
There was a problem hiding this comment.
Could you check how this resolves same-named tables in different schemas? Would this correctly retain s1 for id, or could the second table overwrite the lookup?
SELECT s1.my_table.id
FROM s1.my_table CROSS JOIN s2.my_table
…ery qualifier A CTE named after a physical table no longer links its columns to that table, and a column qualified as schema.table.column resolves to that schema's table when two same-named tables are joined. Each SELECT's sources are read once per statement.
…nd cut the SQL view footer anywhere A CTE body sees only the CTEs before it in a non-recursive WITH, and an UNNEST, VALUES or LATERAL source is never read as a warehouse table, so an unqualified column is not given to the only real table beside it. The engine steps block is cut wherever its marker starts, not only at a line start.
…ias as a source name only for UNNEST
Code Review ✅ Approved 🟡 Medium risk 3 closed / 3 findingsAdding SQL-derived MicroStrategy column lineage and modeling API lookups could attach incorrect column relationships or increase ingestion latency. Adds MicroStrategy column-level lineage from cube SQL to data model columns, so table-to-data-model edges now carry the column pairs the SQL reads. Resolved in this session: an unclosed-comment test input that never reached the comment branch, a derived-table alias that could resolve to a same-named outer table, and Hive/Spark LATERAL VIEW columns being read as the only table's columns. No open findings remain. ✅ 3 closed✅ Quality: Unclosed-comment test input never reaches the
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
…to data models (#37945) * Fixes #37803: MicroStrategy column-level lineage from cube SQL to data models (#37804) * MicroStrategy: skip documents, parse cube SQL once, dedupe columns - Tell Report Services documents, templates and themes from dossiers by viewMedia (the rule MicroStrategy's mstrio-py SDK uses) and skip them before reading a definition the dossier API cannot serve. - Parse each cube's SQL once per cube and dialect instead of once per dbServicePrefixes entry and dossier; skip a prefix whose database does not match the table's qualifier. - Give repeated data model column names a suffix, and drop a repeated object. - Say when a dataset is a report rather than a cube. * MicroStrategy: suffix repeated column names in id order A dataset can list its objects in another order on a later run; suffixes given in listing order would then move a column name to another object. * MicroStrategy: column-level lineage from cube SQL to data models Data model columns are matched on the warehouse columns each projection of the cube SQL reads, not on MicroStrategy's generated aliases: schema attributes through their form expressions (modeling API), Data Import objects through the names the import derives from columns. Metrics of schema cubes get no column edge. * MicroStrategy: compare every table qualifier in column lineage Two tables sharing a name in different schemas or projects could be linked to each other's columns. Forms name their physical table as the SQL does (table prefix, else namespace), a 403 alone means missing privileges, and a column parse failure keeps the table list. * MicroStrategy: cache an unreadable schema attribute and warn once * MicroStrategy: link schema attribute column lineage to the attribute column The lineage view draws no edge to a nested data model column, so pairs that targeted an attribute form (Order.ID) were stored but never shown. * MicroStrategy: tighten column lineage matching from review Data Import objects match the column of the same name, else one unique normalized match that keeps letters of every script; nested queries resolve columns against their own aliases; comment-led passes are read; a refused table read stops modeling calls like a refused attribute read. * MicroStrategy: bound the service lookup caches The dialect and database-name caches are now LRUs capped at CACHE_SIZE, like the connector's other caches, and database names are read with model_str. * MicroStrategy: skip leading SQL comments without a backtracking regex A repeated comment group in a regex backtracked exponentially on an unclosed /* (CodeQL). Comments are now skipped by a linear scan, and passes are split on blank lines, then rejoined where no statement starts. * MicroStrategy: split cube SQL passes in one scan and resolve correlated columns Passes split on a blank line before a statement, never inside a comment or quoted text; an unclosed comment ends the scan without swallowing the pass before it. A correlated column resolves against enclosing queries when its own query has no such alias. An object listed twice in a dataset counts once for name matching. * MicroStrategy: stop alias lookups at derived tables and honour dialect escapes An alias a query defines as a derived table ends the lookup there, so it never resolves to a same-named outer table. Quoted text in the pass split honours backslash escapes in the dialects sqlglot reads them in, and its end is found by a forward scan, so an unclosed string stays linear. --------- Co-authored-by: Pablo Takara <[email protected]> (cherry picked from commit b2c8af2) * MicroStrategy: link no column to Data Import objects that share a name --------- Co-authored-by: Pablo Takara <[email protected]>
Describe your changes:
Fixes #37803
MicroStrategy lineage stopped at table → data model. Each of those edges now carries the column pairs the cube's SQL supports.
WJXBFS1,CATEGORY0). A data model column is matched on the warehouse columns a projection reads. The SQL is read pass by pass, since passes are separated by blank lines, not semicolons.Order), not the form's nested child (Order.ID): the lineage view draws no edge to a nested column. This needs the service account to read schema objects; on HTTP 403, the run logs one warning, makes no further modeling calls and keeps table lineage.Order Id↔order_id): the column of the same name, else the one column whose normalized name matches (letters of every script kept). An ambiguous match gets no edge.WJXBFSnto metrics by position would be a guess.Type of change:
High-level design:
The rules are recorded in a v6 amendment to ADR:2026-11-05-microstrategy-charts-are-named-by-dossier-and-the-search-is-paged.
column_lineage.pyreads the (table, column) pairs each projection reads, with sqlglot.client.pyreads attribute forms, logical tables and dataset types, each cached per id.metadata.pyadds the pairs to each table → data model edge.The cost is one modeling call per schema attribute and per logical table per run.
Tests:
Use cases covered
CATEGORY0,WJXBFS1) maps through the column it reads.Unit tests
ingestion/tests/unit/topology/dashboard/test_microstrategy.py: 74 pass. The source-side tests fail on Fixes #37777: MicroStrategy skips documents, parses cube SQL once and routes lineage by project #37778's code, and the two same-name-table tests fail if tables are matched on their name alone.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
E2E verdict: ✅ pass. #37778 (base) vs this PR, each on a fresh service of a local OpenMetadata server.
WJXBFS1metric alias);orders.status → Status,products.product_name → Product,order_items.order_id → Order; metric unmappedlu_category.CATEGORY_DESC → Category,lu_region.REGION_NAME → Regionlu_item,lu_employee) get no pairs, because the local MySQL tables were ingested without the columns the cube reads.UI screen recording:
Ingestion-only change; screenshots of the lineage page (Column layer) for the trial's Data Import cube.
Before (#37778): table lines only, no column lines.

After (this PR): each warehouse column linked to its data model column.

Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.Reviewed
7d7a5dfb883. One 🔴 fixed: same-named tables in different schemas or projects could be linked; every qualifier is now compared, and forms use the table prefix. Five 🟡 fixed: an edge-level test, a parse timeout, 403-only privilege detection, the ADR wording and the doc wording. Second pass clean. Follow-up: schema pairs targeted nested form columns, which the lineage page never draws; they now target the attribute column, checked in the UI. Review fixes (Unicode and ambiguous name matches, nested-query aliases, comment-led passes, a refused table read): 6 regression tests, each failing before the fix; trial E2E and UI unchanged (22 pairs).Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under
docs/decisions/(see itsREADME.md). This description is gone fromgit logafter the squash-merge.I have added tests around the new logic.
For connector/ingestion changes: I updated the documentation.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with no new actionable issues found.Summary
Adds column lineage from MicroStrategy cube SQL to data model columns while keeping table edges when column lookup fails.
Reviews (15) · Last reviewed commit: "MicroStrategy: skip a bracket-quoted nam..." · Reviewed by Greptile