From 574b5af721f60dbcb4568d7ae44f2a56f6dbf5a3 Mon Sep 17 00:00:00 2001 From: Niall Woodward Date: Mon, 6 May 2024 17:55:01 +0100 Subject: [PATCH] 5.1.0 --- .changes/5.1.0.md | 15 ++++++++++++++ CHANGELOG.md | 16 +++++++++++++++ dbt_project.yml | 2 +- models/hourly_spend.sql | 43 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 .changes/5.1.0.md diff --git a/.changes/5.1.0.md b/.changes/5.1.0.md new file mode 100644 index 0000000..0c77423 --- /dev/null +++ b/.changes/5.1.0.md @@ -0,0 +1,15 @@ +## dbt-snowflake-monitoring 5.1.0 - May 06, 2024 + +### Features + +- Support more usage types ([#152](https://github.com/get-select/dbt-snowflake-monitoring/pull/152)) + +### Fixes + +- Update to use new service_type values ([#151](https://github.com/get-select/dbt-snowflake-monitoring/pull/151)) +- Calculate net cloud services costs for reader accounts ([#153](https://github.com/get-select/dbt-snowflake-monitoring/pull/153)) + +### Contributors +- [@fernandobrito](https://github.com/fernandobrito) (Features) +- [@stumelius](https://github.com/stumelius) (Fixes) + diff --git a/CHANGELOG.md b/CHANGELOG.md index 8522d32..a008311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## dbt-snowflake-monitoring 5.1.0 - May 06, 2024 + +### Features + +- Support more usage types ([#152](https://github.com/get-select/dbt-snowflake-monitoring/pull/152)) + +### Fixes + +- Update to use new service_type values ([#151](https://github.com/get-select/dbt-snowflake-monitoring/pull/151)) +- Calculate net cloud services costs for reader accounts ([#153](https://github.com/get-select/dbt-snowflake-monitoring/pull/153)) + +### Contributors +- [@fernandobrito](https://github.com/fernandobrito) (Features) +- [@stumelius](https://github.com/stumelius) (Fixes) + + ## dbt-snowflake-monitoring 5.0.4 - March 15, 2024 ### Fixes diff --git a/dbt_project.yml b/dbt_project.yml index 26f4e9a..0c8b09a 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'dbt_snowflake_monitoring' -version: '5.0.4' +version: '5.1.0' config-version: 2 profile: dbt_snowflake_monitoring diff --git a/models/hourly_spend.sql b/models/hourly_spend.sql index 14633c2..76fc1a8 100644 --- a/models/hourly_spend.sql +++ b/models/hourly_spend.sql @@ -217,8 +217,7 @@ logging_spend_hourly as ( -- For now we just use the daily reported usage and evenly distribute it across the day -- More detailed information can be found on READER_ACCOUNT_USAGE.* {% set reader_usage_types = [ - 'reader compute', 'reader storage', 'reader cloud services', - 'reader data transfer', 'reader adj for incl cloud services' + 'reader compute', 'reader storage', 'reader data transfer' ] %} {%- for reader_usage_type in reader_usage_types %} @@ -240,6 +239,42 @@ logging_spend_hourly as ( ), {% endfor %} +reader_adj_for_incl_cloud_services_hourly as ( + select + hours.hour, + INITCAP('reader adj for incl cloud services') as service, + null as storage_type, + null as warehouse_name, + null as database_name, + coalesce(stg_usage_in_currency_daily.usage_in_currency / hours.hours_thus_far, 0) as spend, + 0 as spend_net_cloud_services, + stg_usage_in_currency_daily.currency as currency + from hours + left join {{ ref('stg_usage_in_currency_daily') }} as stg_usage_in_currency_daily on + stg_usage_in_currency_daily.account_locator = {{ account_locator() }} + and stg_usage_in_currency_daily.usage_type = 'reader adj for incl cloud services' + and hours.hour::date = stg_usage_in_currency_daily.usage_date +), + +reader_cloud_services_hourly as ( + select + hours.hour, + INITCAP('reader cloud services') as service, + null as storage_type, + null as warehouse_name, + null as database_name, + coalesce(stg_usage_in_currency_daily.usage_in_currency / hours.hours_thus_far, 0) as spend, + coalesce(stg_usage_in_currency_daily.usage_in_currency / hours.hours_thus_far, 0) + reader_adj_for_incl_cloud_services_hourly.spend as spend_net_cloud_services, + stg_usage_in_currency_daily.currency as currency + from hours + left join {{ ref('stg_usage_in_currency_daily') }} on + stg_usage_in_currency_daily.account_locator = {{ account_locator() }} + and stg_usage_in_currency_daily.usage_type = 'reader cloud services' + and hours.hour::date = stg_usage_in_currency_daily.usage_date + left join reader_adj_for_incl_cloud_services_hourly on + hours.hour = reader_adj_for_incl_cloud_services_hourly.hour +), + compute_spend_hourly as ( select hours.hour, @@ -651,6 +686,10 @@ unioned as ( select * from "{{ reader_usage_type }}_spend_hourly" union all {%- endfor %} + select * from reader_adj_for_incl_cloud_services_hourly + union all + select * from reader_cloud_services_hourly + union all select * from compute_spend_hourly union all select * from adj_for_incl_cloud_services_hourly