Skip to content

fix(tables): keep schemaDefinition when dbt adds a data model [Backport #38285 - 2.0] - #38462

Merged
harshsoni2024 merged 1 commit into
2.0from
backport-38285-2.0
Nov 23, 2026
Merged

harshsoni2024 merged 1 commit into
2.0from
backport-38285-2.0

Conversation

@harshsoni2024

@harshsoni2024 harshsoni2024 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #38285 (5bd5fa2) to 2.0. Issue: #38427.

What

PUT /v1/tables/{id}/dataModel deleted the table's schemaDefinition, and later metadata ingestion runs never brought it back. dbt ingestion calls this endpoint for every dbt model and source it matches to a table. #38285 has the full description.

  • TableRepository.addDataModel now reads the whole stored row before writing it back, so it no longer drops schemaDefinition.
  • The bulk sourceHash skip no longer applies when the stored row lacks a schemaDefinition that the request carries. The next ingestion run therefore restores the definitions that were already deleted.

Differences from the main commit

None. The pick applied cleanly and has the same git patch-id --stable as 5bd5fa2. Every method and test helper it uses exists on 2.0 with the same signature.

Tests

  • New tests: TableResourceIT#put_dataModel_keepsSchemaDefinition and BulkSourceHashFastPathIT#test_matchingSourceHash_storesSchemaDefinitionTheRowLacks fail on 2.0 without the fix (expected: <CREATE VIEW …> but was: <null>) and pass with it.
  • Full classes: TableResourceIT, BulkSourceHashFastPathIT and TableDataModelCertificationIT on MySQL + Elasticsearch, parallel lane: 337 run, 0 failures, 0 errors. The 9 skips are the existing capability gates.
  • Upgrade from the released 2.0.8, in Docker. The agents' requests were replayed with the released 2.0.8 ingestion client.
    • On 2.0.8, the dbt agent's PUT /tables/{id}/dataModel deleted a view's definition without changing its version.
    • The same database was then upgraded in place to this branch's build (2.0.10), and migrations ran. The metadata agent's next PUT /tables/bulk restored the definition (version 0.2 → 0.3). That request had the same sourceHash and overrideMetadata=false. A second dbt PUT kept the definition.
    • A view created after the upgrade kept its definition through the dbt PUT.
  • spotless:check passes on openmetadata-service and openmetadata-integration-tests.

Type of change

  • Bug fix

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The behavior looks correct, but the explicit Java style requirements must be satisfied before merging.

Findings

  1. P2 New declarations miss required `final` ▶
  2. P2 Test repeats its view name ▶

Summary

Preserves schemaDefinition when dbt adds a data model and lets bulk ingestion restore definitions lost by earlier writes.

  • Adding dbt details keeps the view’s saved SQL definition.
  • Bulk ingestion restores missing view SQL even when its source hash matches.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[dbt adds a data model] --> B[Read complete stored table]
  B --> C[Merge model and save]
  C --> D[Keep stored schema definition]
  E[Bulk ingestion with matching hash] --> F{Incoming definition missing from storage?}
  F -->|Yes| G[Run normal update and restore definition]
  F -->|No| H[Skip unchanged table]
Loading

Reviews (1) · Last reviewed commit: "fix(tables): keep schemaDefinition when ..." · Reviewed by Greptile

@harshsoni2024
harshsoni2024 requested a review from a team as a code owner November 23, 2026 09:27
@harshsoni2024 harshsoni2024 added the safe to test Add this label to run secure Github workflows on PRs label Nov 23, 2026
@harshsoni2024
harshsoni2024 requested review from harshach and removed request for a team November 23, 2026 09:27
@harshsoni2024 harshsoni2024 added the safe to test Add this label to run secure Github workflows on PRs label Nov 23, 2026
@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.

@gitar-bot

gitar-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Preserving schemaDefinition on data-model PUTs and bypassing hash skips for missing definitions could trigger fuller table metadata updates during ingestion.

Backports the fix that keeps schemaDefinition intact when dbt calls PUT /v1/tables/{id}/dataModel, by reading the full stored row before writing and skipping the bulk sourceHash fast path when a stored row lacks a definition the request carries. 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

* writes the entire row back with {@code dao.update}, so it cannot start from {@code get()}: that
* nulls every field not requested, and the write then deleted them, schemaDefinition among them.
*/
private Table getWholeStoredTable(UUID tableId) {

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.

P2 New declarations miss required final

The new helpers and tests omit final from parameters and local variables that never change. CLAUDE.md requires it for both. Add it to the new declarations, including tableId here, stored and incoming in hasLostSourceFields, and the new test variables. This repository requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


// The stored row lacks a definition its sourceHash covers: the state a write that dropped
// the definition leaves behind. Re-sending it under the same hash must still store it.
BulkApi.upsert("tables", List.of(view(ns, schemaFqn, "fp_lost_ddl", VIEW_DDL)));

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.

P2 Test repeats its view name

The new test repeats "fp_lost_ddl" when creating and updating the same view. CLAUDE.md requires repeated strings to have one named definition. Define the view name once and reuse it so the requests cannot drift apart. This repository requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@harshsoni2024
harshsoni2024 merged commit a36c9db into 2.0 Nov 23, 2026
62 of 79 checks passed
@harshsoni2024
harshsoni2024 deleted the backport-38285-2.0 branch November 23, 2026 13:04
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.

1 participant