<budget_name>!GET_SPENDING_HISTORY

View the spending history for a budget.

See also:

<budget_name>!GET_SERVICE_TYPE_USAGE

Syntax

<budget_name>!GET_SPENDING_HISTORY( [ TIME_LOWER_BOUND => <constant_expr> ,
                                      TIME_UPPER_BOUND => <constant_expr> ] )
Copy

Optional arguments

TIME_LOWER_BOUND => constant_expr, . TIME_UPPER_BOUND => constant_expr

Time range (in UTC timestamp format) during which the spending occurred.

You must set both lower and upper time bounds to limit the results by a time range.

Returns

The function returns the following columns:

Column Name

Data Type

Description

MEASUREMENT_DATE

DATE

Date when the usage occurred.

SERVICE_TYPE

VARCHAR

Type of service that is consuming credits, which can be one of the following:

  • AUTO_CLUSTERING

  • HYBRID_TABLE_REQUESTS

  • MATERIALIZED_VIEW

  • PIPE

  • QUERY_ACCELERATION

  • SEARCH_OPTIMIZATION

  • SERVERLESS_TASK

  • SNOWPIPE_STREAMING

  • WAREHOUSE_METERING

  • WAREHOUSE_METERING_READER

CREDITS_SPENT

FLOAT

Number of credits used.

Access control requirements

  • The following minimum privileges and roles are required to view results for custom budgets:

    • Any instance role for the budget instance.

    • USAGE privilege on the database and schema that contains the budget instance.

  • The following role is required to view results for the account budget:

    Any application role for the account budget.

For more information, see Budgets roles and privileges.

Usage notes

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

View the spending history for budget my_budget in schema budget_db.budget_schema:

CALL budget_db.budget_schema.my_budget!GET_SPENDING_HISTORY();
Copy

View the spending history for the last 7 days for the account budget:

CALL snowflake.local.account_root_budget!GET_SPENDING_HISTORY(
  TIME_LOWER_BOUND=>dateadd('days', -7, current_timestamp()),
  TIME_UPPER_BOUND=>current_timestamp()
);
Copy