Categories:

System Functions

SYSTEM$GET_TAG

Returns the tag value associated with the specified Snowflake object or column. Returns NULL if a tag is not set on the specified Snowflake object or column.

Syntax

SYSTEM$GET_TAG( '<tag_name>' , '<obj_name>' , '<obj_domain>' )
Copy

Arguments

'tag_name'

The name of the tag as a string.

The name is the key in the key-value pair of the tag. For example, in the tag cost_center = 'sales', cost_center is the key-name of the tag. For this argument, use 'cost_center'.

'obj_name'

The name of the object as a string.

For example, if a table name is my_table, use 'my_table' as the name of the object.

To specify a column, use the format <table_name>.<column_name>. For example, my_table.revenue.

For more information, see Object Identifiers.

'obj_domain'

The domain of the object (e.g. TABLE, WAREHOUSE) as a string. If a tag is assigned to a table or view column, the domain is COLUMN.

Use one of the following values:

  • 'ACCOUNT'

  • 'ALERT'

  • 'COLUMN'

  • 'DATABASE'

  • 'INTEGRATION'

  • 'PROCEDURE'

  • 'ROLE'

  • 'SCHEMA'

  • 'SHARE'

  • 'STAGE'

  • 'STREAM'

  • 'TABLE'—Use this for all table-like objects such as views, materialized views, and external tables.

  • 'TASK'

  • 'USER'

  • 'WAREHOUSE'

Usage Notes

  • Using this function requires:

Examples

Returns NULL if a tag is not associated to the specified object:

select system$get_tag('cost_center', 'my_table', 'table');

+-----------------------------------------------------+
| SYSTEM$GET_TAG('COST_CENTER', 'MY_TABLE', 'TABLE')  |
+-----------------------------------------------------+
| NULL                                                |
+-----------------------------------------------------+
Copy

Returns the tag value for the specified table. The tag value is the string component of the key = 'value' pair in the tag:

select system$get_tag('cost_center', 'my_table', 'table');

-----------------------------------------------------+
| SYSTEM$GET_TAG('COST_CENTER', 'MY_TABLE', 'TABLE') |
+----------------------------------------------------+
| sales                                              |
+----------------------------------------------------+
Copy

Returns the tag value for the specified column:

select system$get_tag('fiscal_quarter', 'my_table.revenue', 'column');

+----------------------------------------------------------------+
| SYSTEM$GET_TAG('FISCAL_QUARTER', 'MY_TABLE.REVENUE', 'COLUMN') |
+----------------------------------------------------------------+
| Q1                                                             |
+----------------------------------------------------------------+
Copy