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.
This function returns credit usage within the last 6 months.
- See also:
WAREHOUSE_METERING_HISTORY( DATE_RANGE_START => <constant_expr> [ , DATE_RANGE_END => <constant_expr> ] [ , WAREHOUSE_NAME => '<string>' ] )
DATE_RANGE_START => constant_expr
- The starting date, within the last 6 months, for which warehouse usage is returned.
DATE_RANGE_END => constant_expr
The 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.
Default: All warehouses that ran during the specified date range.
- 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 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.
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||TEXT||Name of the warehouse.|
|CREDITS_USED||NUMBER||Number of credits billed for this warehouse in this hour.|
Retrieve hourly warehouse usage over the past 10 days for all warehouses that ran during this time period:
select * from table(information_schema.warehouse_metering_history(dateadd('days',-10,current_date())));
Retrieve hourly warehouse usage for the
testingwh warehouse on a specified date:
select * from table(information_schema.warehouse_metering_history('2017-10-23', '2017-10-23', 'testingwh'));