Categories:

System functions (Information)

SYSTEM$SHOW_BUDGETS_FOR_RESOURCE¶

Returns a string containing a list of the budgets that track a specified resource (for example, a table or a schema). Currently, a resource can be tracked by one budget.

See also:

<budget_name>!GET_LINKED_RESOURCES

Syntax¶

SYSTEM$SHOW_BUDGETS_FOR_RESOURCE( '<resource_domain>' , '<resource_name>' )
Copy

Arguments¶

'resource_domain'

Domain of the resource. You can specify one of the following values:

  • compute_pool

  • database

  • materialized_view

  • pipe

  • schema

  • table

  • task

  • warehouse

'resource_name'

Name of the resource (for example, the name of the table).

Returns¶

Returns a VARCHAR value containing the comma-delimited list of the fully qualified names of the budgets for the resource. The list is surrounded by square brackets.

If there are no budgets tracking the specified resource, the function returns a string containing an empty pair of square brackets ([]).

Usage notes¶

  • Currently, a resource can be tracked by only one budget.

  • If a resource was automatically added to a budget (for example, because a table is in a database that was added to a budget), the function returns that budget. Unlike the <budget_name>!GET_LINKED_RESOURCES method, this function allows you to determine if a resource was added automatically to a budget.

Examples¶

The following example returns the list of budgets that track the schema named my_db.my_schema:

SELECT SYSTEM$SHOW_BUDGETS_FOR_RESOURCE('SCHEMA', 'my_db.my_schema');
Copy
+---------------------------------------------------------------+
| SYSTEM$SHOW_BUDGETS_FOR_RESOURCE('SCHEMA', 'MY_DB.MY_SCHEMA') |
|---------------------------------------------------------------|
| [BUDGETS_DB.BUDGETS_SCHEMA.MY_BUDGET]                         |
+---------------------------------------------------------------+

The following example returns the list of budgets that track the table named my_db.my_schema.my_table. In this example, the table is not tracked by any budget, so the function returns an empty list.

SELECT SYSTEM$SHOW_BUDGETS_FOR_RESOURCE('TABLE', 'my_db.my_schema.my_table');
Copy
+-----------------------------------------------------------------------+
| SYSTEM$SHOW_BUDGETS_FOR_RESOURCE('TABLE', 'MY_DB.MY_SCHEMA.MY_TABLE') |
|-----------------------------------------------------------------------|
| []                                                                    |
+-----------------------------------------------------------------------+