From the code above, when checking the new_tag.split(.)[2], meaning, the tag name, later in all_tag_name.append(tag_name), it should also add the split(.)[2], otherwise it is adding the complete new_tag name, considering as: data_base.schema_name.tag_name. We should append only the tag_name.
After applying the change below, adding as well the split we have:
During tag creation, if two columns use the same tag, the macro is trying to create the same tag twice.
The error message we get is the one below:
Object 'DB_NAME.SCHEMA_NAME.TAG_NAME' already exists.
In our case, we apply tags using masking policies in Snowflake. And we want to apply the same tag for different columns.
The problem here is in macro create_tag_if_missing:
From the code above, when checking the new_tag.split(.)[2], meaning, the tag name, later in all_tag_name.append(tag_name), it should also add the split(.)[2], otherwise it is adding the complete new_tag name, considering as: data_base.schema_name.tag_name. We should append only the tag_name.
After applying the change below, adding as well the split we have:
This fixes the all_tag_names.append