Skip to content

Fixes #34279: [Trino] Use model_str for the schema name in cross-database lineage - #34385

Merged
mohittilala merged 5 commits into
open-metadata:mainfrom
zerafachris:fix/trino-cross-db-lineage-schema-name-34279
Nov 11, 2026
Merged

mohittilala merged 5 commits into
open-metadata:mainfrom
zerafachris:fix/trino-cross-db-lineage-schema-name-34279

Conversation

@zerafachris

@zerafachris zerafachris commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Why

Fixes #34279.

TrinoLineageSource._get_cross_database_schema_fqn called .root on trino_table.databaseSchema.name, treating it as a Pydantic RootModel. EntityReference.name is typed as Optional[str], not a root model, so every invocation of processCrossDatabaseLineage: true raised:

AttributeError: 'str' object has no attribute 'root'

The entire cross-database lineage step therefore failed for every table, leaving the pipeline as failed/partialSuccess.

What changed

ingestion/src/metadata/ingestion/source/database/trino/lineage.py — one line:

# before
trino_schema_name = trino_table.databaseSchema.name.root

# after
trino_schema_name = model_str(trino_table.databaseSchema.name)

model_str (from metadata.ingestion.ometa.utils) already handles both str and RootModel values — exactly the right defensive wrapper here.

Tests

ingestion/tests/unit/topology/database/test_trino_lineage.py (new file):

  • test_plain_str_name_does_not_raise — parametrised over three schema names; confirms no AttributeError is raised and the schema name appears in the constructed FQN fallback.
  • test_mapping_entry_returned_verbatim — pre-populated mapping is returned as-is.
  • test_none_schema_name_no_fqn_returns_none — both databaseSchema and fullyQualifiedName absent → None.

Prepared with AI assistance (Claude Code, Anthropic), reviewed for correctness before submission.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous test concern is fixed and no new actionable issues were found.

Summary

Fixes Trino cross-database lineage by using model_str() instead of reading .root from databaseSchema.name.

  • Trino lineage resolves schema names stored as plain strings.

Reviews (2) · Last reviewed commit: "fix(trino): sort imports and assert the ..." · Reviewed by Greptile

…ge (open-metadata#34279)

EntityReference.name is typed as plain str; calling .root on it raised
AttributeError for every run of processCrossDatabaseLineage=true, so the
entire cross-database step failed.  Replace .root with model_str(), which
handles both str and RootModel values safely.

Fixes open-metadata#34279

Prepared with AI assistance (Claude Code, Anthropic), reviewed for correctness before submission.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@zerafachris
zerafachris requested a review from a team as a code owner October 1, 2026 14:15
@zerafachris
zerafachris requested a review from TeddyCr October 1, 2026 14:15
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@IceS2
IceS2 requested review from mohittilala and removed request for TeddyCr October 7, 2026 08:57
@ulixius9 ulixius9 added the safe to test Add this label to run secure Github workflows on PRs label Oct 26, 2026
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@ulixius9 ulixius9 added the safe to test Add this label to run secure Github workflows on PRs label Oct 26, 2026
@ulixius9
ulixius9 enabled auto-merge October 26, 2026 11:11
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

auto-merge was automatically disabled October 27, 2026 06:42

Head branch was pushed to by a user without write access

@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@zerafachris

Copy link
Copy Markdown
Contributor Author

@harshsoni2024 Updated and rebased cleanly on main — ready for review / safe to test when you have a chance!

- Fold the three cross-database schema tests into the sibling Trino lineage test file and drop the new file
- Model databaseSchema.name as a plain str in the existing cross-database test, matching EntityReference, so it also fails on the old .root access
@mohittilala mohittilala changed the title fix(trino): use model_str() for databaseSchema.name in cross-db lineage (#34279) Fixes #34279: [Trino] Use model_str for the schema name in cross-database lineage Nov 4, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@mohittilala mohittilala added the safe to test Add this label to run secure Github workflows on PRs label Nov 5, 2026
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot

gitar-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Converting Trino schema names with model_str() changes cross-database lineage resolution; a wrong value could attach lineage to the wrong schema.

Fixes cross-database lineage in Trino by replacing .root with model_str() for databaseSchema.name, which is typed as Optional[str] rather than a Pydantic RootModel. The change resolves the AttributeError that caused lineage processing to fail on every table. Comprehensive unit tests confirm the fix handles string names, schema mappings, and null cases correctly.

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

@mohittilala mohittilala added the safe to test Add this label to run secure Github workflows on PRs label Nov 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@mohittilala
mohittilala enabled auto-merge (squash) November 11, 2026 04:39
@mohittilala
mohittilala merged commit 9052935 into open-metadata:main Nov 11, 2026
88 of 97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[Trino] Cross-database lineage fails: 'str' object has no attribute 'root' in _get_cross_database_schema_fqn (2.0.1)

4 participants