Skip to content

Fixes #37544: Doris view lineage resolves the internal catalog and parses Doris view DDL - #37706

Merged
IceS2 merged 2 commits into
open-metadata:mainfrom
morningman:doris-view-lineage
Nov 18, 2026
Merged

IceS2 merged 2 commits into
open-metadata:mainfrom
morningman:doris-view-lineage

Conversation

@morningman

@morningman morningman commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #37544

Doris view lineage produced no edges, and the definitions of materialized views that #37705 ingests would not have produced column lineage either:

  • Doris qualifies every name in the definitions it stores with the catalog, `internal`.`db`.`t` for its own tables. Lineage read internal as the database and looked up <service>.internal.<db>.<t>, but the connector ingests the internal catalog as the database databaseName, default when it is not set. No table matched, so no view had lineage. The only workaround was databaseName: internal.
  • Doris is parsed with the MySQL dialect. The DDL of an async materialized view carries BUILD ... REFRESH ..., a key clause, PARTITION BY, DISTRIBUTED BY and PROPERTIES between the column list and AS: sqlglot falls back to a Command, sqlfluff reports it unparsable, and sqlparse finds the tables but turns the four-part column names (`internal`.`db`.`alias`.`col`) into <default>.internal.<col>, which match no column.
  • A column of a view or a materialized view can carry a COMMENT in the column list. Since Doris prints the column names with backquotes ([fix](view) Quote view column names in SHOW CREATE VIEW output apache/doris#66467, in 4.1.5 and later: (`region` comment 'sales region',`manager`, ...)), the parsers drop the lineage of every commented column.

This change:

  • Adds doris/resolution.py, loaded by service type like ClickHouse's. A reference whose database part is exactly internal (catalog names are case sensitive in Doris) resolves under the database of the service, read from the service's databaseName once per service (bounded LRUCache with the shared LRU_CACHE_SIZE). Another catalog name is kept: it will name the database of that catalog once external catalogs are read (Doris: ingest external catalogs (Hive, Iceberg, JDBC, …) as databases #37549). A reference without a service keeps internal, since no database is known; so does a reference whose service cannot be read, with a warning, and that failure is not cached. The rule is recorded in ADR:2026-11-13-doris-internal-catalog-names-the-service-database, since external catalogs and any Doris-side lineage emitter have to name tables the same way.
  • Adds doris/lineage_utils.py with a view lineage parser factory, plugged in through DorisLineageSource.get_view_lineage_parser_factory as ADR:2026-11-05-connectors-adapt-view-lineage-parsing describes. It reads the definition with sqlglot's doris dialect; for a materialized view it drops the properties, and for any view it drops the column comments, then hands the parsers the plain CREATE VIEW name (columns) AS <query> in the MySQL dialect. The returned parser keeps the original query, query hash and masked query. A view without column comments, any other statement, and a definition sqlglot cannot read are parsed as before.

Known limits:

Part of #37537.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • internal references resolve under default and under a configured databaseName, never under another database of the service; the database name is read once per service.
  • Another catalog keeps its name; a reference without a service (None, *) keeps internal and reads no service; a service that cannot be read leaves the reference unresolved with a warning, and the next read succeeds.
  • Materialized view DDL as Doris master prints it (schedule and commit triggers, incremental refresh with fallback and its KEY clause, comments, hash and random distribution, partitioning by an expression, a join, a CTE with UNION ALL) and as Doris 4.1.3 prints it (column list without backquotes, with and without comments) parses with its source tables, target and column lineage, and keeps the original query, hash and masked query.
  • A view with column comments keeps the lineage of the commented columns.
  • A view without comments, a query, a CTAS, a materialized view with an unquoted - or reserved-word name, and DDL sqlglot cannot read parse as before.
  • View lineage end to end (get_view_lineage with the factory and the resolver) links a materialized view and a view to both source tables with their column lineage, with and without databaseName.

Unit tests

  • I added unit tests for the new/changed logic.
  • File added: ingestion/tests/unit/source/database/doris/test_doris_view_lineage.py, 22 tests. The DDL is what Doris master prints (PROPERTIES shortened). Resolution goes through the real OpenMetadata client over a stubbed REST transport.
  • On main the module does not import. With each part of the change removed in turn: without the resolver 5 tests fail, without the DDL rewrite 9, keeping the column comments 4, without the factory registered on the lineage source 3.
  • make unit_ingestion ARGS="-n 0 tests/unit/source/database/doris tests/unit/topology/database/test_doris.py tests/unit/utils/test_table_binding_resolution.py tests/unit/entity_resolution tests/unit/lineage tests/unit/topology/database/test_clickhouse_lineage_utils.py": 731 passed, 2 skipped. test_all_connector_resolvers_load_without_specs_or_connector_drivers loads the Doris resolver with the drivers blocked.
  • Coverage %: 95% on doris/resolution.py, 96% on doris/lineage_utils.py.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Started a local Apache Doris master build with test databases: views over tables, one of them with column comments, and 11 async materialized views covering every clause SHOW CREATE MATERIALIZED VIEW prints (refresh triggers, incremental refresh, key clauses, partitioning, distribution, comments), a join, a CTE with UNION ALL, and a name printed without quotes.

  2. Ran view lineage end to end without a server: the Doris source's metadata path built the table entities, a stand-in for the OpenMetadata API served them, and get_view_lineage ran for every table the lineage producer picks (views and materialized views with a definition), with the Doris lineage source's parser factory:

    Edges Column lineage
    main (4 views) 0 0
    this change (4 views) 6 11
    Fixes #37540: Doris materialized views, views and table DDL as Doris reports them #37705 (4 views, 11 materialized views) 0 0
    this change on top of Fixes #37540: Doris materialized views, views and table DDL as Doris reports them #37705 20 36

    Every view and materialized view links to all its source tables, with a column lineage entry for each column read from a table, except COUNT(*) columns, the CHAR(255) columns of one view that the connector drops on main (Doris: CHAR(255) columns are silently dropped during metadata ingestion #37590), and the materialized view whose name is printed without quotes (table-level only).

  3. With databaseName: doris_prod, the same edges link local_doris.doris_prod.* tables.

  4. Repeated step 2 on Doris 4.1.3 (apache/doris:all-in-one-4.1.3), which has no incremental refresh: the 13 views and materialized views it can create get the same edges and column lineage as on master (18 edges, 31 column lineage entries with Fixes #37540: Doris materialized views, views and table DDL as Doris reports them #37705, 6 and 11 without), before and after. Doris 4.1.3 prints column lists without backquotes, which the parsers read with or without comments.

  5. make py_format_check and make static-checks pass (0 errors, no new warnings); scripts/harness/check_decision_records.py reports the records clean.

UI screen recording:

Not applicable — ingestion-only bug fix with no UI change.

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. (N/A: no schema change)

  • 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). (N/A: not a UI change)

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md and fixed every 🔴 finding, or answered it on the line below.

  • Decision check: if this PR decides something the next contributor could undo, it adds a record under docs/decisions/.

  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Fixes Doris view lineage by mapping the internal catalog to the service’s database and simplifying view definitions before parsing.

  • Doris view definitions now produce lineage from their source tables and columns.
  • Doris lineage matches internal catalog names to the service database.

morningman identifies two known limits: materialized-view names printed without required quotes retain table-level lineage only, and COUNT(*) has no column lineage. No actionable issues found.

Reviews (1) · Last reviewed commit: "Merge branch 'main' into doris-view-line..." · Reviewed by Greptile

…L as views

Doris names its own tables `internal`.`db`.`t` in the definitions of
views and materialized views. Lineage took the internal catalog for the
database and looked up <service>.internal.<db>.<t>, but the connector
ingests the internal catalog as the database databaseName, default when
unset, so no Doris view had lineage.

Add a Doris table resolution that maps an exact `internal` qualifier to
the database of the service, read from its databaseName once per
service. Other catalog names and references without a service keep
their names, and a service that cannot be read leaves the reference as
it is, with a warning. The rule is recorded in
docs/decisions/2026-11-13-doris-internal-catalog-names-the-service-database.md.

Doris is parsed with the MySQL dialect. The DDL of an async
materialized view, with its refresh, key, partition, distribution and
PROPERTIES clauses, parses only as far as its tables, without column
lineage, and a COMMENT on a backquoted column of a view drops that
column's lineage. Add a view lineage parser factory that reads the DDL
with sqlglot's Doris dialect, drops those clauses and the column
comments, and parses the plain CREATE VIEW, keeping the original query,
hash and masked query. Any other definition is parsed as before.
@morningman
morningman requested a review from a team as a code owner November 13, 2026 01:27
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This 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 skip-pr-checks label.

@gitar-bot

gitar-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Doris lineage resolution and view-DDL normalization change table and column lineage; mistakes could link views to incorrect source tables or columns.

Fixes Doris view lineage so the internal catalog resolves to the service database, and parses Doris view and materialized view DDL (including column comments and properties) for table and column lineage. No issues found.

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

@IceS2
IceS2 merged commit b1ba230 into open-metadata:main Nov 18, 2026
50 of 52 checks passed
Khairajani added a commit to morningman/OpenMetadata that referenced this pull request Nov 18, 2026
Resolve the Doris connector conflicts with open-metadata#37705 and open-metadata#37706: read the DDL
through _get_create_statement, and keep a failing per-table partition lookup
from dropping the table (it returns no partition details instead).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doris: view lineage produces no edges because of the internal catalog prefix

2 participants