<budget_name>!GET_SPENDING_HISTORY

View the spending history for a budget.

See also:

<budget_name>!GET_SERVICE_TYPE_USAGE

语法

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

可选实参

TIME_LOWER_BOUND => constant_expr,
TIME_UPPER_BOUND => constant_expr

支出发生的时间范围(UTC 时间戳格式)。

您必须同时设置时间下限和时间上限,以便根据时间范围限定结果。

返回

该函数返回以下列:

Column NameData TypeDescription
MEASUREMENT_DATEDATEDate when the usage occurred.
SERVICE_TYPEVARCHAR

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

  • AUTO_CLUSTERING
  • DATA_QUALITY_MONITORING
  • HYBRID_TABLE_REQUESTS
  • MATERIALIZED_VIEW
  • PIPE
  • QUERY_ACCELERATION
  • SEARCH_OPTIMIZATION
  • SERVERLESS_ALERTS
  • SERVERLESS_TASK
  • SNOWPIPE_STREAMING
  • WAREHOUSE_METERING
  • WAREHOUSE_METERING_READER
CREDITS_SPENTFLOATNumber of credits used.

访问控制要求

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.

示例

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

CALL budget_db.budget_schema.my_budget!GET_SPENDING_HISTORY();

查看账户预算最近 7 天的支出历史记录:

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