Skip to content

Fixes 5989: Ingest Tableau calculated measures as Metric entities - #34216

Merged
harshsoni2024 merged 7 commits into
mainfrom
manila-v2
Oct 6, 2026
Merged

harshsoni2024 merged 7 commits into
mainfrom
manila-v2

Conversation

@ulixius9

Copy link
Copy Markdown
Member

Describe your changes:

Fixes open-metadata/openmetadata-collate#5989

I added Tableau support for includeMetrics: every visible CalculatedField with the MEASURE role becomes a Metric entity, with its formula, type (falling back to the formula's aggregate when Tableau Cloud reports a null aggregation), unit, dimensions, relatedMetrics, and its data model as assets. Metric lineage now reflects where a measure is actually defined — a Tableau measure is a field of its datasource and a LookML measure a field of its view — so both Tableau and Looker draw Table → DataModel → Metric (column: the measure's model column → metric FQN) plus Metric → Metric, instead of a direct Table → Metric edge that skipped the model.

Type of change:

  • New feature

High-level design:

  • Tableau (tableau/metrics.py, new): pure mapping from DatasourceField → CreateMetricRequest; metrics are emitted parents-first (the server resolves relatedMetrics on create). Metric names are a stable hash of service + datasource id + field id, since Metric has no service namespace. The GraphQL query now fetches role/aggregation/defaultFormat/isHidden/upstreamFields for calculated fields.
  • Emission point: yield_dashboard_lineage runs after the data-model Barrier, so the data model the metric references (as asset and lineage source) is already persisted.
  • Lineage source = the data model: every datasource field / LookML field (measures included) is already a column of its data model, and the existing Table → DataModel column lineage feeds it. Drawing DataModel → Metric keeps a single true path, gives lineage to metrics whose warehouse table can't be resolved (extracts, files, derived-table views), and removed the source-table caching the direct edge needed (_datasource_source_tables, _view_source_refs, table_column_references, an LRU cache).
  • Lineage is sent as OMetaFQNLineageRequest, not through yield_lineage_request: with overrideLineage the sink would delete a metric's other incoming edges.
  • Known limit: Looker without git credentials ingests no view data models, so its metrics get only Metric → Metric lineage (unchanged from before).

Tests:

Use cases covered

  • Tableau calculated measures become Metrics with type/unit/dimensions/assets; hidden fields and plain columns are skipped; filtered-out data models emit nothing; includeMetrics off emits nothing
  • Derived measures reference their parent metric and are written after it
  • Tableau and Looker metric lineage comes from the declaring data model with the measure's column; no metric links straight to a table even with a DB service configured
  • Looker measures reported by the API but absent from LookML still link to their view (entity-level)

Unit tests

  • test_tableau_metrics.py (new), test_looker_metric_stage.py, test_looker_measures.py, test_looker_issue_regressions.py
  • 312 Looker + Tableau unit tests pass. Coverage: tableau/metrics.py 100%, looker/measures.py 96% (tableau/metadata.py 63%, looker/metadata.py 77% whole-file)

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not added; covered by unit tests driving the real lineage/data-model stages.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Not yet run against a live Tableau site; unit-tested only.

UI screen recording / screenshots:

Not applicable.

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.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Calculated fields with the MEASURE role become Metric entities behind the
includeMetrics flag, with table->metric column lineage and metric->metric
lineage for measures built from other measures.
…data model

A Tableau calculated measure is a field of its datasource and a LookML measure
a field of its view; both are already columns of that data model, fed by the
model's own Table -> DataModel lineage. Draw DataModel -> Metric (column: the
measure's model column -> metric FQN) instead of skipping the model with a
direct Table -> Metric edge, and drop the source-table plumbing that edge
needed. Tableau also falls back to the formula's aggregate when Tableau Cloud
reports a null aggregation.
Copilot AI balanced review requested due to automatic review settings September 29, 2026 11:04
@ulixius9
ulixius9 requested a review from a team as a code owner September 29, 2026 11:04
@ulixius9
ulixius9 requested a review from TeddyCr September 29, 2026 11:04

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 reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

  • Linked issue open-metadata/openmetadata-collate#5989 does not exist or is not accessible.

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.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit e15e496ebf0397214e0b35b348fc214191e0bbbf in Playwright run 36853171635, attempt 1.

✅ 105 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 47m 57s

⏱️ Max setup 6m 7s · max shard execution 14m 16s · max shard-job elapsed before upload 20m 30s · reporting 4s

🌐 252.30 requests/attempt · 1.82 app boots/UI scenario · 0.00% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 252.3 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 1.82 per UI scenario (207 boots / 114 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 40 0 0 0 0 0
✅ Shard ingestion-01 24 0 0 0 0 0
✅ Shard ingestion-02 41 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

…ModelFilterPattern

_get_datamodel looks the model up on the server, so a model excluded now but
ingested by an earlier run still emitted its calculated measures as Metrics.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 09: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 review overview

🟡 Changes recommended

Raw metric lineage requests bypass override handling, allowing obsolete dependency edges to persist across ingestion runs.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)

…neage

Metric edges bypassed yield_lineage_request, so a measure whose dependencies
changed kept its stale DashboardLineage edges. The sink's delete-by-source is
cached per target, so routing every edge through it clears stale lineage once
and keeps all current edges.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 10:10

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 review overview

🟡 Changes recommended

Two lineage/mapping correctness bugs remain, and PR metadata validation is failing.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Quote-aware comment stripping corrupts URLs in Tableau formulas

ingestion/​src/​metadata/​ingestion/​source/​dashboard/​tableau/​metrics.py:66

This regex removes // inside Tableau string literals, not just comments. For example, the valid outer aggregate SUM(IF CONTAINS([url], "http://example.com") THEN [sales] END) is truncated to SUM(IF CONTAINS([url], "http: and formula_aggregation returns None; on Tableau Cloud, where aggregation is null, the metric is therefore incorrectly classified as OTHER. Please strip comments with a quote-aware scanner/parser and add URL/quoted-parenthesis regression cases.

…lineage in yield_lineage_request

_views_cache is keyed by view name only, so two projects declaring the same
view handed each other's metrics the wrong data model for assets and lineage.
Metrics now resolve their view through a (project, view) keyed cache.

yield_lineage_request already forwards OMetaFQNLineageRequest (the sink and
OMetaLineageRequest accept it); widen its annotation so basedpyright passes.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:05
@gitar-bot

gitar-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk · Adds Tableau metric entities and changes Tableau/Looker lineage ingestion behavior.

Adds Tableau support for ingesting calculated measures as Metric entities with formula, type, unit, dimensions, and related metrics. Metric lineage now correctly flows through data models (Table → DataModel → Metric) instead of direct table-to-metric edges, and metrics excluded by dataModelFilterPattern are now properly skipped. All 312 unit tests pass with comprehensive coverage.

✅ 1 closed
✅ Edge Case: Metrics still emitted for data models excluded by dataModelFilterPattern

📄 ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py:838-841 📄 ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py:1159-1173 📄 ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py:289-292
yield_datamodel_metrics treats a missing _get_datamodel result as "filtered out". But _get_datamodel fetches the model from the OpenMetadata server by FQN and never checks dataModelFilterPattern. So when a datasource matches the filter in this run and its data model already exists on the server (from an earlier run before the filter was added, or when stale models aren't deleted), its calculated measures are still ingested as Metrics, with lineage and assets pointing at a model the user excluded. To fix this, run the same filter_by_datamodel(self.source_config.dataModelFilterPattern, datasource.name or datasource.id) check before _get_datamodel and skip the datasource when it matches.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

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 review overview

🟡 Changes recommended

Cross-datasource Tableau metric dependencies are dropped, and the new Looker view cache is unbounded.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Cross-datasource metric dependencies lose related metrics and lineage

ingestion/​src/​metadata/​ingestion/​source/​dashboard/​tableau/​metadata.py:870

Related metrics are ordered and resolved only within one datasource, but embedded datasources are processed before their upstreamDatasources. If an embedded calculated measure references a calculated field defined by its published datasource, the parent is absent from this per-datasource emitted set (and related_metric_names only scans the embedded fields), so both relatedMetrics and Metric→Metric lineage are silently dropped. Build a global field-to-defining-datasource index and topologically order the flattened datasource metrics before emitting them.

@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@harshsoni2024
harshsoni2024 added this pull request to the merge queue Oct 6, 2026
Merged via the queue into main with commit 07a3cba Oct 6, 2026
122 of 123 checks passed
@harshsoni2024
harshsoni2024 deleted the manila-v2 branch October 6, 2026 11:39

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants