<budget_ name>!ADD_ SHARED_ RESOURCE¶
Adds a shared resource to a custom budget. When you add a shared resource, consumption is tracked only if the resource is used by certain users. These users are tagged with a tag-value pair that was added to the budget using the SET_USER_TAGS method.
For more information, see Using budgets for AI features (shared resources).
Syntax¶
Arguments¶
'domain'The type of resource being added to the budget. Valid values:
AI FUNCTIONCORTEX CODECORTEX AGENTSNOWFLAKE INTELLIGENCE
Unless you specify a second argument, the budget tracks consumption for all resources within the specified domain.
'instance'Optional. Specifies a specific resource within the selected
domainto add to the budget.For domains that support instance-level selection (such as
AI FUNCTIONandCORTEX CODE), this argument allows you to track a specific function or interface.For object-backed domains (
CORTEX AGENTandSNOWFLAKE INTELLIGENCE), pass an object reference for the instance value: use the serialized string returned by SYSTEM$REFERENCE, or a subquery such as(SELECT SYSTEM$REFERENCE(...)).If you don’t specify a second argument, the budget tracks all instances within the domain.
Examples:
- AI Functions:
AI_CLASSIFY,AI_COMPLETE - Cortex Code:
CORTEX_CODE_CLI,CORTEX_CODE_SNOWSIGHT
- AI Functions:
Returns¶
Returns a VARCHAR value that indicates whether or not the resource was successfully added to the budget.
If the resource could not be added to the budget, the function returns an error message.
Access control requirements¶
The following privileges and roles are required to call this method for a custom budget:
- ADMIN instance role for the budget instance.
- USAGE privilege on the database and schema that contain the budget instance.
- USAGE privilege on the database and schema that contain the resource being added (for schema objects).
For more information, see Budgets roles and privileges.
Usage notes¶
- You can only add shared resources to custom budgets.
- To verify the results of the method, call the GET_BUDGET_SCOPE method.
- When all objects of the specified entity type are added (for example, all AI Functions), you can’t add individual resources of that type.
-
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.
Examples¶
Add all AI Functions to the budget:
Add a specific AI function to the budget:
Add all Cortex Code workloads to the budget:
Add the Cortex Code CLI workload to the budget:
Add the Cortex Code Snowsight workload to the budget:
Add all Cortex Agent workloads to the budget:
Add a specific Cortex Agent workload to the budget:
Add all Snowflake Intelligence workloads to the budget:
Add a specific Snowflake Intelligence workload to the budget: