Remove tags that are no longer in the YAML
Describe the bug
When modifying a column's tag in dbt (either adding a new tag or changing an existing tag's key/value), dbt-databricks doesn't remove the previous tag before applying the new one. This results in multiple tags accumulating on a single column instead of replacing the old tag with the new one.
Steps To Reproduce
- Add a tag to a column in your dbt model configuration (e.g.,
tags={'sensitivity': 'low'}) - Run
dbt runto apply the tag in Databricks - Modify the tag in your dbt model (e.g., change to
tags={'sensitivity': 'high'}) - Run
dbt runagain - Observe in Databricks that the column now has both tags instead of just the updated one
Expected behavior
Before applying a tag to a column, dbt-databricks should remove any existing tags on that column that are no longer in the yaml file of the model, ensuring that the column only has the currently defined tag from the dbt model configuration. This is related to another issue we defined earlier: https://github.com/databricks/dbt-databricks/issues/1308
System information
The output of dbt --version:
Core:
- installed: 1.10.13
Plugins:
- databricks: 1.10.19
The operating system you're using: MacOS
The output of python --version:
Python 3.12.12
Classifying this as an enhancement as this will require work on the adapter side
@SpaltmanDionne From the example that you have written, I ran alter queries (similar to dbt-databricks) on a Databricks warehouse and SET TAGS for the same key will be updated and not appended.
Or did you mean that the tag keys not specified in the model should be deleted from databricks tables?
Hi @SpaltmanDionne the specific scenario that is detailed in the issue description should work fine {'sensitivity': 'low'} -> {'sensitivity': 'high'}. I think probably what you mean is that dbt-databricks can't remove tags on that server side that are removed from the yaml definition. This is a known limitation today in the implentation of column tags.