Skip to content

Commit

Permalink
Use metering_daily_history for daily_billable_cloud_services
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-whitestone committed Feb 19, 2023
1 parent 8e91c58 commit f18f268
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions models/daily_spend.sql
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ _cloud_services_spend_daily as (
group by 1, 2, 3, 4
),


credits_billed_daily as (
select
convert_timezone('UTC', start_time)::date as date,
sum(credits_used_compute) as daily_credits_used_compute,
date,
sum(credits_used_cloud_services) as daily_credits_used_cloud_services,
greatest(daily_credits_used_cloud_services - daily_credits_used_compute * 0.1, 0) as daily_billable_cloud_services
from {{ ref('stg_metering_history') }}
sum(credits_used_cloud_services + credits_adjustment_cloud_services) as daily_billable_cloud_services
from {{ ref('stg_metering_daily_history') }}
where
service_type = 'WAREHOUSE_METERING'
group by 1
),

Expand Down
2 changes: 2 additions & 0 deletions models/staging/stg_metering_daily_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

select
usage_date as date,
service_type,
credits_used_cloud_services,
credits_adjustment_cloud_services
from {{ source('snowflake_account_usage', 'metering_daily_history') }}

0 comments on commit f18f268

Please sign in to comment.