Skip to content
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

Merged
merged 3 commits into from
Feb 6, 2025
Merged

Conversation

fernandobrito
Copy link
Contributor

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 our hourly_spend.

@fernandobrito fernandobrito requested a deployment to Approve Integration Tests February 6, 2025 14:06 — with GitHub Actions Waiting
@fernandobrito fernandobrito temporarily deployed to Approve Integration Tests February 6, 2025 14:37 — with GitHub Actions Inactive
Comment on lines 462 to 489
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
),

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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

@fernandobrito fernandobrito deployed to Approve Integration Tests February 6, 2025 18:03 — with GitHub Actions Active
@fernandobrito
Copy link
Contributor Author

I was able to remove 2 more CTEs by renaming the service from metering_history so it matches with rate_sheet_daily and 1 more CTE by using a case to store the warehouse name as the CTE was doing before

@NiallRees NiallRees merged commit a91d37c into main Feb 6, 2025
1 check passed
@NiallRees NiallRees deleted the increase-service-spend-coverage branch February 6, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants