<budget_name>!GET_BUDGET_SCOPE

Returns the resources and tags that have been added to a custom budget. Helps determine which resource consumption is tracked by the budget.

The list does not include:

  • Objects that were added automatically (for example, compute pools and warehouses created and owned by a Snowflake Native App).
  • Objects that were added when a tag was added to the budget.

语法

<budget_name>!GET_BUDGET_SCOPE()

返回

该方法返回一个具有以下键的 JSON 对象:

resource_tags

已添加到预算的资源标签。如果资源带有这些标签,则属于预算。包含以下字段:

operator

用于资源标签的匹配逻辑。可以是以下值之一:

  • UNION: A resource is included in the budget if it is tagged with any of the tag-value pairs in the tags array.
  • INTERSECTION: A resource must be tagged with all of the tag-value pairs in the tags array to be included in the budget.
tags

标签对象数组,每个标签对象都包含以下字段:

tagId

标签的内部标识符。

tagDatabase

包含标签的数据库。

tagSchema

包含标签的架构。

tagName

标签的名称。

tagValues

与标签关联的标签值数组。

resources

已直接添加到预算的资源数组。各对象包含以下字段:

resourceId

资源的内部标识符。

resourceName

资源的名称。

resourceDomain

Domain of the resource (for example, WAREHOUSE, DATABASE, TABLE).

schemaName

包含资源的架构。

databaseName

包含资源的数据库。

访问控制要求

查看自定义预算的结果需要以下最低权限和角色:

  • ADMIN instance role for the budget instance.
  • 对包含预算实例的数据库和架构的 USAGE 权限。

For more information, see Budgets roles and privileges.

使用说明

  • 此方法只能在 自定义预算 实例上调用。
  • Calling this method does not return the object. Because of this, you can’t use method chaining to call another method on the return value of this method. Instead, call each method in a separate SQL statement.

示例

Get all resources and tags that have been added to the budget_db.budget_schema.my_budget budget:

CALL budget_db.budget_schema.my_budget!GET_BUDGET_SCOPE();