Skip to content

Fixes 38832: Apply dbt source metadata to existing database schemas - #38913

Open
Vamsi-klu wants to merge 5 commits into
open-metadata:mainfrom
Vamsi-klu:codex/38832-dbt-schema-metadata
Open

Vamsi-klu wants to merge 5 commits into
open-metadata:mainfrom
Vamsi-klu:codex/38832-dbt-schema-metadata

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

Fixes #38832

dbt keeps metadata declared on a source in source_meta. We already use the table-level metadata, but the physical DatabaseSchema still has to be updated by hand. This adds an includeSchemaMetadata option so teams can keep those schema values in dbt. The default is off for saved workflows.

Type of change

  • New feature

High-level design

The dbt source groups eligible declarations by the UUID of an existing schema, then writes one conditional patch per schema. It uses a uniquely resolved source table's schema when available and otherwise tries an exact schema name in the configured service. Direct owners and domains are kept, glossary terms are additive, and custom properties are updated only for the keys declared in dbt. Conflicting declarations leave the affected field alone and identify the source IDs in ingestion status.

On a version conflict, the worker fetches the schema again and rebuilds the patch. A repeat run with the same declarations keeps the certification dates and schema version. If the bot cannot read the configured certification classification, a fully qualified certification label can still be validated by the server.

Tests

  • 27 manifest-based regressions passed, including default-off, Cloud artifacts, a dotted catalog name with a matching table in another service, unique and ambiguous case variants, conflicting declarations, concurrent edits, and repeat runs. schema_metadata.py reached 90.12% line coverage.
  • The three existing dbt suites passed 363 tests and 43 subtests.
  • make generate, model freshness, the Python lock, Python formatting, and UI schema parsing passed. Scoped Python type checks found no errors. The full locked type check stopped at a package download.
  • MySQL/Elasticsearch passed DatabaseSchemaResourceIT#conditionalIngestionPatchPreservesServerCertificationDates. The normal ingestion bot made the conditional PATCH, a stale request returned 412, and an identical replay preserved the stored version and certification dates.
  • Two full Python dbt runs passed on a live 2.1.1 catalog as the normal ingestion bot. The first made one conditional schema PATCH and persisted ownership, domain, tier, glossary, the integer custom property set to 0, and Certification.Gold. All three table models were stored. The second made zero schema PATCHes and preserved the full schema snapshot, including the version and certification timestamps.
  • All four dbt form Jest cases passed, including a save and reopen regression for the new toggle. An unfiltered run of the same file hit the default five-second timeout in eight other cases.

To try it, enable includeSchemaMetadata on a dbt workflow with a source mapped to an existing schema. Run it with one source-level declaration, check the schema fields, then run the same artifact again and compare the version and certification expiry.

UI screen recording

The existing schema-driven dbt form renders the new option. The Docker recording is pending.

Checklist

  • Read the contribution guide and reviewed the change against REVIEW.md.
  • Added regression coverage and regenerated the workflow contracts.
  • Updated the example YAML and dbt workflow help.
  • Recorded the opt-in and write policy. The configuration field is optional and existing workflows use the default.
  • Verify the full dbt workflow and a repeat run as the normal ingestion bot.

The write policy is open for feedback on the issue. Could a maintainer also add the issue to Shipping?

@gitar-bot

gitar-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findings

Opt-in dbt ingestion patches existing schema metadata, so source declarations may alter catalog ownership, certification, tags, and custom properties.

Adds an includeSchemaMetadata option to the dbt workflow so source-level source_meta values are applied to existing DatabaseSchema entities using conditional patches with version-conflict retry. The case-insensitive table binding issue was resolved by rejecting ambiguous bindings and reporting them as failures. No open issues found.

✅ 1 closed
✅ Bug: Case-insensitive table binding is rejected and reported as a failure

📄 ingestion/src/metadata/ingestion/source/database/dbt/schema_metadata.py:178-192 📄 ingestion/src/metadata/ingestion/source/database/dbt/schema_metadata.py:214-215 📄 ingestion/src/metadata/ingestion/source/database/dbt/metadata.py:1154-1166
_resolve_table can bind a source to a table whose FQN differs from the manifest only in case. The entity-resolution engine has a CASE_INSENSITIVE_EXACT tier and the ES FQN search also matches case-insensitively. This is the normal Snowflake setup: dbt names are RAW_DB.RAW and OpenMetadata stores raw_db.raw. _verified_binding compares actual_fqn == expected_fqn exactly. When the service, catalog and schema are all known it does continue instead of searching, and once the loop ends if table: raises _SchemaWriteError("Physical source table does not match its declared scope"). The result: every such source records status.failed and contributes nothing, and the exact-schema fallback never runs. Compare the FQNs case-insensitively, or match by table id when the resolved table falls in the declared scope.

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

@Vamsi-klu
Vamsi-klu marked this pull request as ready for review November 27, 2026 04:52
@Vamsi-klu
Vamsi-klu requested review from a team as code owners November 27, 2026 04:52
@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.

This branch has not been deployed

No deployments
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.

Support schema-level meta data ingestion in the dbt connector

2 participants