Repository navigation
Fixes 36357: Hex data models and column-level lineage from SQL cells (2.1) - #36387
Conversation
Each Hex project now gets one HexDataModel with a struct column per SQL
cell, holding the columns that cell outputs. Column lineage runs from the
warehouse table columns to those cells, then data model -> dashboard.
The SQL comes from the project export (falling back to the cells API),
which names each cell's result variable, so chained SQL cells are inlined
as CTEs the way Hex runs them and trace back to the warehouse. Input
parameters ({{ x }}) parse as values, and sqlglot resolves each output
column with table schemas from OpenMetadata. The warehouse query history
path stays as the fallback when no cells can be read.
The Hex client retries 429 responses, as Hex rate-limits each endpoint
to about 30 requests per minute.
(cherry picked from commit 33b47d3)
A project whose cells or data connections can't be read keeps the data model an earlier run created, marked as seen and still linked to its dashboard, instead of being deleted over a failed API call. A failed data connections read is retried for the next project rather than cached. A table reference matching several tables (the same schema.table in two services, or a bare name) now resolves to none instead of the first search hit. (cherry picked from commit 16ad476)
…ailures - A table reference resolves only when exactly one table matches across all db service prefixes, and only with a schema: from the SQL, the Hex connection's defaults (now read from the data connections API) or the prefix. A bare name is no longer matched in any service. - Tables the warehouse query history found but no cell resolved still link to the dashboard, instead of cells replacing that lineage. - The cells API stands in for the export only when the export is not allowed (403/404). A transient export failure, or a failed table search, now leaves the project's data model as it is rather than rewriting it from incomplete cells. - The data model lookup for the dashboard link can no longer fail the dashboard, and an unread project's model is marked as seen without one. (cherry picked from commit 22d96d4)
… names - Columns resolve case-insensitively, quoted or not, so Snowflake's "REGION" and Postgres' "createdAt" match the table's columns instead of losing their lineage (a table-qualified one used to drop the whole cell). A failed qualify now keeps the columns, without lineage. A column passed straight through keeps its table's casing. - A cell is stored for the cells chained after it once its references name the tables found, so tables it found through its connection's defaults still resolve from a dataframe cell. - Column names are made unique after they are made valid, so two outputs can no longer collapse into one rejected name. - Data connections the token can't read (403/404) are treated as none known, rather than as a transient failure that would keep every data model unchanged forever. (cherry picked from commit 6af0b43)
- A table reference a cell could not resolve now carries the database and schema it was searched under, so a chained cell inlining it, which has no connection defaults of its own, can't match a table elsewhere. - A quoted alias keeps the spelling it was given in the data model. (cherry picked from commit 791ff4a)
- A table reference a cell could not resolve is marked, and a chained cell inlining it leaves it unresolved, rather than searching it again without that cell's connection defaults (which could match a table in another database through a prefix). - A warehouse cell only inlines upstream cells on its own connection, as Hex does; SQL on dataframes can read any cell's result. - A UNION branch selecting * from an unknown table no longer drops the cell: sqlglot's IndexError there now keeps the columns without lineage. (cherry picked from commit c42a857)
…odels - The names a dataframe SQL cell reads are dataframes, so they are never looked up as warehouse tables; such a cell reaches the warehouse only through the cells it chains to. - Outputs sharing a name (o.id, c.id, or * over a join) are all kept, the repeats suffixed, instead of all but the first being dropped. - dataModelFilterPattern applies to Hex data models. (cherry picked from commit cacf30b)
- An inlined upstream cell keeps its own WITH, and table references are found scope by scope, so a CTE defined inside an upstream cell can no longer capture a warehouse table of the same name the downstream cell reads. - Each cell's column group is named by its stable id (the export's cellId, the cells API's staticId) with the label as its display name, so a renamed or reordered cell keeps its columns' descriptions, tags and lineage. - Lineage never targets a data model excluded by dataModelFilterPattern, which this run deletes. (cherry picked from commit c5d461c)
- Add ADR:2026-10-27-hex-project-is-one-data-model-with-a-column-group-per-cell-id:
the data model and its column groups are named by project and cell
id, tables resolve only uniquely and with a schema, and a failed read
keeps the existing data model.
- A cell over 10,000 nodes isn't stored for inlining, so a notebook where
each cell joins the ones before it no longer grows exponentially; the
cells chained to it keep their columns, without lineage.
- Inlining keeps WITH RECURSIVE, so a recursive CTE isn't looked up as
a table.
- Only the first branch of a Jinja {% if %} is kept, so the SQL parses.
- A bare * over a join with a dataframe is spelled out per table, so the
known table's columns are kept.
(cherry picked from commit 61debe6)
The kept-model link now applies dataModelFilterPattern like the data model and lineage stages, so a dashboard is never pointed at a data model this run deletes. (cherry picked from commit 05f7d5c)
…caps - A t.* is dropped only where t names an unknown table in that SELECT's own scope, so an alias reused across CTEs no longer loses the known table's columns (and their lineage). - The table lookup memo is an LRUCache(1000), and a project keeps at most 100,000 nodes of cell queries for chaining; cells past it are stored as unresolvable rather than read as warehouse tables. - The decision record now also states the child column casing, the inlining caps and the 429 retry budget. (cherry picked from commit d996669)
❌ 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 ( |
- 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)
| 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 |
There was a problem hiding this comment.
Saved model loses dashboard link
When reading an existing model fails while preserving a failed SQL cell, this path marks the model as seen but yields no model record. _kept_data_model_fqn then skips keeping the link because the cached cell list is not None. The next dashboard request sends dataModels=[], removing the saved model's dashboard link even if the server has recovered.
Track this skipped update as an incomplete read and preserve the existing link.
Knowledge Base Used: Ingestion connectors
| if data_connections is None: | ||
| if not self.source_config.includeDataModels or self._data_model_exists(project): | ||
| return None | ||
| data_connections = {} |
There was a problem hiding this comment.
Dashboard lineage stops updating
When Hex denies access to data connections, _data_connections now stays None. With includeDataModels=false, this guard returns before reading any SQL cells. That blocks dashboard lineage even for fully qualified table names that need no connection defaults. Tables absent from the available query history get no dashboard link.
Previously, denied access returned {} and those cells were still traced. Keep the protection for existing models without disabling dashboard-only lineage.
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)
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.
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)
Code Review ✅ Approved🟡 Medium risk · Hex ingestion now builds project data models and infers column lineage; SQL or table-resolution mistakes could misrepresent catalog dependencies. Adds Hex data model ingestion with one 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 #36357
Backport of #36371 to
2.1: the Hex connector ingests oneHexDataModelper 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 and inADR:2026-10-27-hex-project-is-one-data-model-with-a-column-group-per-cell-id(included here).The commits of #36371 are cherry-picked with
-x, including its last commit (c02d176, a kept data model stays linked).2.1is merged in. Its Hex source-URL fix (#36419) conflicted inhex/client.py, so that file and the data model's optionalsourceUrlare resolved the same way as onmain. Apart from 2.1's own existing baseline entries, the PR's files on this branch are now identical tomain. Also carries #36541 (cherry-picked with-x): cells reading a broken cell keep their data model groups, the fix for the edge case Gitar raised on #36388.Type of change:
Tests:
Unit tests
PYTHONPATH=src python -m pytest tests/unit/topology/dashboard/test_hex*.pyon this branch → 146 passed.ruff check/ruff format --check,check_ruff_suppressions.py --check,basedpyrightonhex/(0 errors),check_decision_records.py, and the impact-map--check-branch.Backend integration tests
HexDataModelenum value. Its impacted Java unit tests and ITs passed on Fixes 36357: Hex data models and column-level lineage from project SQL cells #36371 (678 unit, 1,884 IT, 0 failed); they were not re-run on this branch.Manual testing performed
HexDataModels and accepted all 74 column links.UI screen recording:
Not applicable: ingestion connector change with no UI code.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.mdpasses plus the bot reviews), applied unchanged.Fix the lost dashboard link and skipped dashboard-only lineage before merging.
Findings
Summary
Adds one
HexDataModelper Hex project, with stable column groups for SQL cells and column lineage through chained cells.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Hex[Hex project export] --> Cells[SQL cells] Cells --> Resolve[Resolve warehouse tables and chained cells] Resolve --> Model[One HexDataModel per project] Tables[Warehouse columns] --> Model Model --> Dashboard[Hex dashboard] History[Warehouse query history] --> DashboardReviews (3) · Last reviewed commit: "Hex: keep models without data connection..." · Reviewed by Greptile