Multi-value tags¶
Overview¶
Standard tags support only a single value per tag on an object. Multi-value tags extend this capability by supporting multiple values associated with the same tag on the same object or column. This is useful when an object needs to be classified with multiple categories that aren’t mutually exclusive.
For example, a table might need to be tagged with multiple data sources (DATA_SOURCE = 'CRM' and DATA_SOURCE = 'ERP')
or multiple compliance requirements (COMPLIANCE = 'GDPR' and COMPLIANCE = 'PCI').
Key characteristics of multi-value tags:
- A tag must be explicitly configured with the MULTI_VALUE = TRUE property to support multiple values.
- After a tag is set to multi-value, it can’t be reverted to a single-value tag.
- You use
ADD VALUEandDROP VALUEoperations to manage multiple values on an object. - The default limit is 10 values per multi-value tag per object.
- Multi-value tags work with tag propagation. The
ON_CONFLICT = MERGEstrategy is available only whenMULTI_VALUE = TRUE.
Multi-value tags vs single-value tags¶
| Topic | Single-value tags | Multi-value tags |
|---|---|---|
| Cardinality | One value per tag per object or column. | Up to 10 values per tag per object by default. |
| Tag definition | Created with default behavior (MULTI_VALUE is false or omitted). | Tag is created or altered with MULTI_VALUE = TRUE. You can’t set MULTI_VALUE back to false. |
| Assigning values | Use SET TAG / UNSET TAG on the object or column. | Use ADD VALUE and DROP VALUE on ALTER TABLE to add or remove values; you can add the first value with ADD VALUE directly. SET TAG replaces the entire value set with the value you set (it doesn’t append). UNSET TAG removes the tag (see ALTER TABLE ADD VALUE and DROP VALUE (multi-value tags)). |
| Propagation conflicts | Propagation uses your tag’s ON_CONFLICT behavior for a single winner value unless you adopt merge semantics separately. | ON_CONFLICT = MERGE is allowed only when the tag has MULTI_VALUE = TRUE; use it so multiple source values can accumulate on the target (for example on views). |
SYSTEM$GET_TAG and policy helpers | Return the one tag value when a single value is present. | Return an error when more than one value exists. Use SYSTEM$TAG_VALUE_CONTAINS for checks, or keep policy logic on single-value tags only (see Multi-value tags and masking policies). |
Creating a multi-value tag¶
To create a tag that supports multiple values, use the MULTI_VALUE = TRUE attribute in the CREATE TAG statement:
You can also create a multi-value tag with propagation enabled:
To convert an existing tag to a multi-value tag, use ALTER TAG:
Note
After a tag is set to multi-value, either at tag creation or by calling ALTER TAG, it can’t be reverted to a single-value tag.
Assigning multiple values to objects¶
After creating a multi-value tag, use ADD VALUE and DROP VALUE on ALTER TABLE to add or remove values.
SET TAG sets the tag to exactly one string and replaces any values already present; it doesn’t append to the set.
Examples follow.
- Assign multiple values to a table tag
To assign tag values to a table:
To remove a specific value:
- Assign multiple values to a column tag
To assign tag values to a column:
You can also modify multiple columns in a single statement:
ALTER TABLE ADD VALUE and DROP VALUE (multi-value tags)¶
Adds or removes values from a multi-value tag on a table or column. This topic describes the ADD VALUE and DROP VALUE syntax for
multi-value tags. For the full ALTER TABLE reference, see ALTER TABLE.
Syntax¶
Table-level operations¶
Column-level operations¶
Multi-column operations¶
You can modify multiple columns in a single statement:
Parameters¶
table_nameThe name of the table to modify.
col_nameThe name of the column to modify (for column-level operations).
'tag_value'The string value to add to or remove from the tag. The value must be a valid string that conforms to any
ALLOWED_VALUESconstraints on the tag.tag_nameThe identifier for the tag. The tag must have
MULTI_VALUE = TRUEset.
Usage notes for ALTER TABLE multi-value operations¶
- The tag must be created with
MULTI_VALUE = TRUE(or converted usingALTER TAG ... SET MULTI_VALUE = TRUE) before you can useADD VALUEorDROP VALUEoperations. Attempting these operations on a single-value tag returns an error. - You can use the standard
SET TAGsyntax, but it replaces the tag’s entire value set with a single string; it doesn’t append. - Adding a duplicate value is a no-op. Dropping a value that does not exist is a no-op.
- When all values are dropped from a multi-value tag on an object, the tag association is removed from that object.
- Multi-value tags can’t be used with the
COPY TAGSoption inCREATE TABLE ... CLONEorCREATE TABLE ... LIKEstatements.
Note
Views receive multi-value tags through tag propagation when the source tables
have multi-value tags with ON_CONFLICT = MERGE. Direct ALTER VIEW ADD VALUE syntax is not supported.
Querying multi-value tags¶
The SYSTEM$GET_TAG function doesn’t support tags with multiple values.
If you call SYSTEM$GET_TAG on an object that has multiple values for a tag, the function returns an error.
If the tag has only one value (even if the tag is configured as multi-value), SYSTEM$GET_TAG returns that value without an error.
For the full reference, see SYSTEM$TAG_VALUE_CONTAINS.
SYSTEM$TAG_ VALUE_ CONTAINS¶
SYSTEM$TAG_VALUE_CONTAINS returns TRUE if the specified multi-value tag on the specified object or column contains the specified
value. It returns FALSE if the value is not present or if the tag is not assigned to the object. Use it whenever you might have more
than one value, because SYSTEM$GET_TAG raises an error when multiple values exist.
Examples¶
You can also use the TAG_REFERENCES and TAG_REFERENCES_ALL_COLUMNS table functions to view all tag values:
You can filter results to a specified tag:
Tag propagation with multi-value tags¶
Multi-value tags work with tag propagation. You can set ON_CONFLICT = MERGE on a tag only when MULTI_VALUE = TRUE; it isn’t valid for single-value tags. When you use the merge strategy, conflicting tag values from multiple source objects are combined into multiple values on the target object.
Views receive multi-value tags through propagation when all the source tables have multi-value tags with ON_CONFLICT = MERGE.
For example, if two source tables have different values for the same propagating tag, a view created from both tables has both values:
Changes to source table tags (adding or dropping values) automatically propagate to dependent objects.
Multi-value tags and masking policies¶
The SYSTEM$GET_TAG_ON_CURRENT_TABLE and SYSTEM$GET_TAG_ON_CURRENT_COLUMN functions, which are used in masking policy and row access policy conditions, don’t support tags with multiple values.
If you need to use tags with masking policies, use single-value tags for the policy logic. You can use multi-value tags on the same objects for other classification purposes, but don’t reference multi-value tags in policy conditions.
For application-level logic that needs to check multi-value tags, use SYSTEM$TAG_VALUE_CONTAINS in your queries:
Limitations¶
- The MULTI_VALUE property can’t be set to FALSE. After a tag is configured as multi-value, it can’t be reverted.
- The default limit is 10 values per multi-value tag per object.
SYSTEM$GET_TAG,SYSTEM$GET_TAG_ON_CURRENT_TABLE, andSYSTEM$GET_TAG_ON_CURRENT_COLUMNreturn an error when called on a tag with multiple values assigned. UseSYSTEM$TAG_VALUE_CONTAINSinstead.- Adding a duplicate value is a no-op (no error is raised, and the value count does not increase).
- ADD VALUE and DROP VALUE operations require the tag to have
MULTI_VALUE = TRUE. Running these operations on a single-value tag returns an error.
Supported objects¶
For the objects you can assign tags to, see Supported objects.