Skip to content

Commit

Permalink
Merge pull request #153 from get-select/5.1.0
Browse files Browse the repository at this point in the history
5.1.0
  • Loading branch information
NiallRees authored May 6, 2024
2 parents 46453d6 + 574b5af commit 94ab20f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .changes/5.1.0.md
Original file line number Diff line number Diff line change
@@ -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)

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'dbt_snowflake_monitoring'
version: '5.0.4'
version: '5.1.0'
config-version: 2

profile: dbt_snowflake_monitoring
Expand Down
43 changes: 41 additions & 2 deletions models/hourly_spend.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 94ab20f

Please sign in to comment.