-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase service spend coverage #173
Conversation
models/hourly_spend.sql
Outdated
materialized_view_spend_hourly as ( | ||
select | ||
hours.hour, | ||
'Materialized Views' as service, | ||
null as storage_type, | ||
null as warehouse_name, | ||
null as database_name, | ||
coalesce( | ||
sum( | ||
stg_metering_history.credits_used * daily_rates.effective_rate | ||
), | ||
0 | ||
) as spend, | ||
spend as spend_net_cloud_services, | ||
any_value(daily_rates.currency) as currency | ||
from hours | ||
left join {{ ref('stg_metering_history') }} as stg_metering_history on | ||
hours.hour = convert_timezone( | ||
'UTC', stg_metering_history.start_time | ||
) | ||
and stg_metering_history.service_type = 'MATERIALIZED_VIEW' | ||
left join {{ ref('daily_rates') }} as daily_rates | ||
on hours.hour::date = daily_rates.date | ||
and daily_rates.service_type = 'MATERIALIZED_VIEW' | ||
and daily_rates.usage_type = 'materialized views' | ||
group by 1, 2, 3, 4 | ||
), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will "rename" this service from Materialized Views
to Materialized View
. If that's a problem, we should revert this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed we're going to keep the 'Materialized Views' name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to rename it from the new source to Materialized Views
and tested it with real data
I was able to remove 2 more CTEs by renaming the service from |
There are new Snowflake services (such as SENSITIVE_DATA_CLASSIFICATION, DATA_QUALITY_MONITORING, SERVERLESS_ALERTS, TRUST_CENTER) which are not covered today by our
hourly_spend
because we have 1 CTE per service.This PR adds a new CTE to catch any service that is in
metering_history
and currently not covered by ourhourly_spend
.