- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2025 01:37 PM
Hi @stefan_erste, I ran into the same situation and managed to get it working from a notebook. The main issue isn’t really the cluster but the way the SQL parser handles the command. When you’re inside PySpark you need to fully qualify the column path with <catalog>.<schema>.<view>.<column>, and also make sure to put backticks around both the tag key and the value, otherwise it throws that syntax error you saw.
For example, what worked for me was something like:
spark.sql("""
SET TAG ON COLUMN workspace.wiliam_lab.vw_sales.customerID
`reporting_field_name` = `Customer Identifier Test`
""")
Once I used this format, the tag showed up in information_schema.column_tags and in the UI as expected. If you plan to loop over a mapping table and apply multiple tags dynamically, the same pattern works fine with f-strings. The only catch is that if you run it more than once with the same key/value, Unity Catalog complains with a duplicate assignment error. To get around that, I either skip when the tag already exists with the same value, or unset it first and then set it again if I need to update the value.
After doing this, I was able to tag my views programmatically without issues. So as long as you backtick the key and value and fully qualify the column name, you should be good to go.
Data Engineer | Machine Learning Engineer
LinkedIn: linkedin.com/in/wiliamrosa