- Categories:
WAREHOUSE_ METERING_ HISTORY¶
This table function can be used in queries to return the hourly credit usage for a single warehouse (or all the warehouses in your account) within a specified date range.
Note
This function is generally deprecated in favor of the ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY view, which provides a more complete data set and supports longer date ranges.
Note
This function does not include credit usage for adaptive warehouses. To view adaptive warehouse usage, use the ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY view.
- See also:
Syntax¶
Arguments¶
Required:
DATE_RANGE_START => constant_exprThe starting date, within the last 6 months, for which warehouse usage is returned.
Optional:
DATE_RANGE_END => constant_exprThe ending date, within the last 6 months, for which warehouse usage is returned.
Default: CURRENT_DATE is used.
WAREHOUSE_NAME => 'string'The name of the warehouse to retrieve credit usage for. Note that the warehouse name must be enclosed in single quotes. Also, if the warehouse name any spaces, mixed-case characters, or special characters, the name must be double-quoted within the single quotes (e.g.
'"My Warehouse"'vs'mywarehouse').Default: All warehouses that ran during the specified date range.
Usage notes¶
- Returns results only for the ACCOUNTADMIN role or any role that has been explicitly granted the MONITOR USAGE global privilege.
- When calling an Information Schema table function, the session must have an INFORMATION_SCHEMA schema in use or the function name must be fully-qualified. For more details, see Snowflake Information Schema.
- The order and structure of the arguments depends on whether the argument keywords (e.g.
DATE_RANGE_START) are included:- The keywords are not required if the arguments are specified in order.
- If the argument keywords are included, the arguments can be specified in any order.
Output¶
The function returns the following columns, ordered by WAREHOUSE_NAME and START_TIME:
| Column Name | Data Type | Description |
|---|---|---|
| START_TIME | TIMESTAMP_LTZ | The beginning of the hour in which this warehouse usage took place. |
| END_TIME | TIMESTAMP_LTZ | The end of the hour in which this warehouse usage took place. |
| WAREHOUSE_NAME | VARCHAR | Name of the warehouse. |
| CREDITS_USED | NUMBER | Number of credits billed for this warehouse in this hour. |
| CREDITS_USED_COMPUTE | NUMBER | Number of credits used for the warehouse in the hour. |
| CREDITS_USED_CLOUD_SERVICES | NUMBER | Number of credits used for cloud services in the hour. |
Examples¶
Retrieve hourly warehouse usage over the past 10 days for all warehouses that ran during this time period:
Retrieve hourly warehouse usage for the testingwh warehouse on a specified date: