Created
March 20, 2024 18:15
-
-
Save ian-whitestone/326f785d6f171ce179de7072894d6eeb to your computer and use it in GitHub Desktop.
https://www.reddit.com/r/snowflake/comments/1bjjvwx/is_there_a_way_to_find_the_exact_amount_of_time/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with | |
warehouse_periods as ( | |
select | |
warehouse_name, | |
timestamp as valid_from, | |
lead(timestamp) over (partition by warehouse_name order by timestamp asc) as valid_to, | |
event_name = 'RESUME_WAREHOUSE' as is_active | |
from snowflake.account_usage.warehouse_events_history | |
where | |
-- double check these names, can't remember exact values | |
event_name in ('RESUME_WAREHOUSE', 'SUSPEND_WAREHOUSE') | |
and event_state = 'COMPLETED' | |
) | |
select | |
*, | |
iff(is_active, datediff('seconds', valid_from, valid_to), 0) as seconds_active | |
from warehouse_periods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In response to https://www.reddit.com/r/snowflake/comments/1bjjvwx/is_there_a_way_to_find_the_exact_amount_of_time/