Skip to content

Fixes 36357: Hex data models and column-level lineage from SQL cells (2.0) - #36388

Merged
ulixius9 merged 8 commits into
2.0from
ulixius9/hex-datamodels-2.0
Oct 29, 2026
Merged

ulixius9 merged 8 commits into
2.0from
ulixius9/hex-datamodels-2.0

Conversation

@ulixius9

@ulixius9 ulixius9 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #36357

Backport of #36371 to 2.0: the Hex connector ingests one HexDataModel per project, with a column group per SQL cell and column-level lineage from the warehouse tables through chained cells to the dashboard. The design, safety rules and review history are in #36371.

The commits of #36371 conflicted on 2.0, so this is a squashed port, followed by #36371's last commit (c02d176, cherry-picked with -x). 2.0 is merged in. Its Hex source-URL fix (#36420) conflicted in hex/client.py, which is resolved the same way as on main. Also carries #36541 (cherry-picked with -x), the fix for Gitar's finding here: cells reading a broken cell keep their data model groups. It was built by three-way merging the PR's changes onto 2.0's Hex files, with these adaptations:

  • Table search errors: es_search_from_fqn on 2.0 has no raise_on_error and returns None for a failed search, the same as for no match. The Hex source runs the FQN search itself, so a search that didn't answer keeps the existing data model rather than reading as "no such table".
  • Tags: the project's tag handling (tag_utils) is kept as it is on 2.0.
  • Typing: build_es_fqn_search_string is typed database_name: str on 2.0, though it handles None; this needed one scoped pyright: ignore.
  • Generated types: the type-generation workflow fails on 2.0, so the HexDataModel TypeScript enum value is Fixes 36357: Hex data models and column-level lineage from project SQL cells #36371's own generated change from main.
  • Decision record: 2.0 now has docs/decisions/, so the record main has (with Fixes 36357: Hex cells reading a broken cell keep their data model groups #36541's v2 amendment) is included and the code's ADR: citation resolves.

Type of change:

  • New feature

Tests:

Unit tests

  • PYTHONPATH=src python -m pytest tests/unit/topology/dashboard/test_hex*.py on this branch → 147 passed. The test fake now answers the raw FQN search, matching the 2.0 code path.
  • Also clean on this branch: ruff check / ruff format --check and basedpyright on hex/ (0 errors).

Backend integration tests

Manual testing performed

  • Ran this branch's Hex code against a live Hex workspace (two demo projects on Snowflake) → the same data models as on main, with all 74 column links. A run against a server was not possible here: the local server is built from main, and 2.0's client models reject its newer fields.

UI screen recording:

Not applicable: ingestion connector change with no UI code.

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.
  • For JSON Schema changes: no migration is needed; it only adds an enum value.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: the logic is Fixes 36357: Hex data models and column-level lineage from project SQL cells #36371 as reviewed there; the 2.0 adaptations are listed above.

RetriggerView in GreptileConfidence Score: 3/5

Fix the two link-preservation gaps before merging.

Findings

  1. P1 Table-only lineage disappears ▶
  2. P1 Saved model link disappears ▶

Summary

Adds one HexDataModel per Hex project, with SQL-cell column groups and warehouse-to-column lineage through chained cells.

  • Hex projects now get data models with column lineage from their SQL cells.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Hex[Hex project export] --> Cells[SQL cells]
  Connections[Hex connections] --> Cells
  Cells --> Resolve[Resolve warehouse tables]
  Resolve --> Model[Project data model]
  Model --> Groups[Column group per cell]
  Resolve --> Links[Table and column lineage]
  Links --> Model
  Model --> Dashboard[Hex dashboard]
  History[Optional warehouse query history] --> Dashboard
Loading

Reviews (2) · Last reviewed commit: "Hex (2.0): a failed read of a table the ..." · Reviewed by Greptile

…L cells (2.0)

Backport of #36371 to 2.0, squashed from 33b47d3, 16ad476,
22d96d4, 6af0b43, 791ff4a, c42a857, cacf30b,
c5d461c, 61debe6, 05f7d5c and d996669.

Adapted to 2.0:
- es_search_from_fqn has no raise_on_error here and returns None for a
  failed search, so the Hex source runs the FQN search itself and treats
  a search that didn't answer as an error, not as "no such table".
- The project's tag handling (tag_utils) is kept as it is on 2.0.
- The decision record is not added: 2.0 has no docs/decisions. The code
  cites ADR:2026-10-27-hex-project-is-one-data-model-with-a-column-group-per-cell-id on main.
@ulixius9
ulixius9 requested a review from a team as a code owner October 28, 2026 05:42
@ulixius9
ulixius9 requested review from mohittilala and removed request for a team October 28, 2026 05:42
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 Oct 28, 2026
- Data connections the token can't read raise HexAccessDeniedError and
  are asked for once per run. Without them an existing data model is left
  as it is instead of being rebuilt without dialects and connection
  defaults; only a project without one gets one.
- A cell whose SQL fails to parse keeps its column group from the
  existing data model, with what users curated on it.
- A column name is parsed out of the lineage leaf rather than split on
  dots, so a quoted "customer.id" is one name.
- A column passed straight through keeps its table column's array
  element type, display type and nested fields.

(cherry picked from commit a6b8920)
…odel

The 2.0 FQN search reads each table it finds; an error there now counts
as a failed search, so the project's existing data model is kept rather
than rebuilt without that cell.
Comment on lines +588 to +590
if not self.source_config.includeDataModels or self._data_model_exists(project):
return None
data_connections = {}

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.

P1 Table-only lineage disappears

With includeDataModels=false, a 403 or 404 from /data-connections now stops all SQL-cell lineage. Previously, denied access returned {}, so SQL that names the schema could still produce table-to-dashboard links. If no warehouse-history fallback is configured, those dashboards now get no lineage.

Keep the saved-model protection separate from table-only lineage so disabling data models does not disable this path.

Knowledge Base Used: Ingestion connectors

Comment on lines +405 to +410
except Exception as exc:
# Without the earlier data model, the groups of the cells that failed would be lost
logger.debug(traceback.format_exc())
logger.warning("Could not read the data model of Hex project %s: %s", dashboard_details.id, exc)
self.datamodel_source_state.add(self._build_fqn(DashboardDataModel, dashboard_details))
return

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.

P1 Saved model link disappears

If a cell fails to parse and reading the saved model's columns then fails, this catch marks the model as seen but does not preserve its dashboard link. The cached cell list is still non-None, so _kept_data_model_fqn refuses to keep the link. No model was emitted into the stage context, so yield_dashboard sends dataModels=[] and the dashboard patch removes the existing link.

Record this skipped update as a keep condition too.

Knowledge Base Used: Ingestion connectors

# Conflicts:
#	ingestion/src/metadata/ingestion/source/dashboard/hex/client.py
…ugh columns

- A data model kept because its existing groups couldn't be read stays linked
  to the dashboard: the data model stage records what it kept and the dashboard
  stage links it, instead of only when the cells couldn't be read.
- A passed-through struct's fields copy only the table column's type, not its
  description, tags, constraint or profile.

(cherry picked from commit c02d176)
…odel in the generated types

Matches the resolution on main (#36371) of the data model sourceUrl against
the workspace-scoped Hex URLs, which return None when the workspace id can't
be read. The generated TypeScript enum value is the one #36371 generated on
main; the type-generation workflow fails on 2.0 so it never added it here.
@ulixius9
ulixius9 requested a review from a team as a code owner October 29, 2026 08:27
@ulixius9
ulixius9 requested review from harsh-vador and removed request for a team October 29, 2026 08:28
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 68%
68.42% (83182/121575) 53.37% (51612/96706) 54.07% (15340/28366)

A cell whose SQL fails keeps its existing group, but the cells reading its
result lost theirs: dataframe SQL over it was dropped and a warehouse cell
searched its name as a table, coming back with UNKNOWN columns. A cell reading
a failed cell now fails too, down the chain, so each keeps its group.

(cherry picked from commit ea7e122)
2.0 now has docs/decisions/, so the record #36371 added on main (with its v2
amendment from #36541) comes along instead of leaving the ADR citation in
hex/metadata.py dangling.
@gitar-bot

gitar-bot Bot commented Oct 29, 2026

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

🟡 Medium risk · Adding Hex project data models and SQL-derived column lineage could misattribute warehouse columns or omit lineage when cell or table resolution is wrong.

Adds Hex data models with column-level lineage from project SQL cells, one HexDataModel per project with a column group per cell. Cells chained on a broken cell now keep their data model group, addressing that finding. No open issues remain.

✅ 1 closed
✅ Edge Case: Cells chained on a broken cell still lose their data model group

📄 ingestion/src/metadata/ingestion/source/dashboard/hex/metadata.py:596-610 📄 ingestion/src/metadata/ingestion/source/dashboard/hex/metadata.py:628-638 📄 ingestion/src/metadata/ingestion/source/dashboard/hex/metadata.py:674-675
When a cell fails to parse, _build_cell_lineage (metadata.py:604-608) now marks it failed=True so its group is kept. But it never registers the cell's resultVariableName in upstream, because upstream.add (line 675) only runs on the success path. Any later cell that reads that result is affected:

  • Dataframe SQL cells (no data connection): inline_upstream_cells inlines nothing, so _build_sql_cell_lineage returns None at lines 634-638. The cell is treated as having no SQL, not as failed, and _data_model_columns drops its group along with the descriptions and tags users added to it.
  • Chained cells on the same connection: the reference to the broken cell is searched as a warehouse table. It fails to resolve, so the group is rebuilt with UNKNOWN columns and loses its column lineage.

The result is that editing one upstream cell into a draft state still wipes the curated groups of every cell that depends on it. This is the case the commit says it fixes ("keep broken cells' groups"). Fix: track the result variable names of failed cells, and mark any cell that references one as failed too, so it keeps its existing group.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

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

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants