fix: apply only new or changed databricks_tags on table re-runs#1572
Open
sd-db wants to merge 1 commit into
Open
fix: apply only new or changed databricks_tags on table re-runs#1572sd-db wants to merge 1 commit into
sd-db wants to merge 1 commit into
Conversation
jprakash-db
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
For the
tablematerialization, dbt re-applies every configureddatabricks_tags(table-level) and column-leveldatabricks_tagson every run viaALTER … SET TAGS— oneALTERper column. When many columns are tagged this dominates run time (eachSET TAGSis ~300ms) even when nothing changed.Root cause
The set-only tag diff already exists (
TagsConfig.get_diff/ColumnTagsConfig.get_diff) but is wired only into the incremental materialization. Thetablepath applies all configured tags unconditionally on every run — both the v1/legacy path and the v2create_table_at.Fix
Reuse the existing diff on the table path. When an existing delta/iceberg table is replaced in place (
CREATE OR REPLACE, which preserves tags), fetch the current server tags and apply only those that are new or changed. Fresh creates and drop+recreates apply all tags (no tags to diff against), and tag-free models skip the fetch entirely.The diff is gated on
replaced_in_place— an existing delta/iceberg table replaced in place — not merely on a relation having existed. A drop+recreate (a non-table type, or a non-delta/iceberg format) produces a fresh table with no inherited tags, so it must apply all configured tags rather than diff against possibly-stale metadata.Tests
New
tests/functional/adapter/tags/test_table_tag_fetch_skips.py:Existing tag and incremental-metadata-fetch suites are unchanged and green.
Closes #1308