Categories:

System Functions

SYSTEM$GET_TAG_ON_CURRENT_COLUMN¶

Returns the tag string value assigned to the column based upon the specified tag or NULL if a tag is not assigned to the specified column.

When the body of a masking policy or projection policy includes this function, the value of a tag assigned to a column can determine the return value of the policy assigned to that column.

Syntax¶

SYSTEM$GET_TAG_ON_CURRENT_COLUMN( '<tag_name>' )
Copy

Arguments¶

'tag_name'

Identifier for the tag as a string.

For example, if the tag is named cost_center use 'cost_center' as the argument.

Usage notes¶

  • Currently, this function can only be used in a masking policy or projection policy condition to dynamically evaluate the tag string value set on a column.

    Snowflake returns an error while using the function in either a SELECT query, a row access policy, a view, or a user-defined function (UDF).

  • Note that this function applies to all table-like objects (e.g. views).

  • The tag must exist when calling this system function; otherwise, Snowflake returns the following error message:

    Tag '<tag_name>' does not exist or not authorized.
    
    Copy

Examples¶

Masking policy

For a contextual example on how to use this function with a masking policy, see Example 2: Protect column data based on the column tag string value.

Projection policy

When the following projection policy is assigned to a column, the value of the tags.accounting_col tag on that column must be public in order to project the column.

CREATE PROJECTION POLICY mypolicy
AS () RETURNS PROJECTION_CONSTRAINT ->
CASE
  WHEN SYSTEM$GET_TAG_ON_CURRENT_COLUMN('tags.accounting_col') = 'public'
    THEN PROJECTION_CONSTRAINT(ALLOW => true)
  ELSE PROJECTION_CONSTRAINT(ALLOW => false)
END;
Copy