Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
NiallRees authored Nov 30, 2023
1 parent b9ae271 commit 82dfe94
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions models/cost_per_query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ query_cost as (
inner join credits_billed_hourly
on query_seconds_per_hour.warehouse_id = credits_billed_hourly.warehouse_id
and query_seconds_per_hour.hour = credits_billed_hourly.hour
inner join {{ ref('daily_rates') }} AS daily_rates
inner join {{ ref('daily_rates') }} as daily_rates
on date(query_seconds_per_hour.start_time) = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'compute'
Expand Down Expand Up @@ -157,7 +157,7 @@ select
from all_queries
inner join credits_billed_daily
on date(all_queries.start_time) = credits_billed_daily.date
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on date(all_queries.start_time) = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'cloud services'
Expand Down
46 changes: 23 additions & 23 deletions models/hourly_spend.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ storage_spend_hourly as (
any_value(daily_rates.currency) as currency
from hours
left join storage_terabytes_daily on hours.date = convert_timezone('UTC', storage_terabytes_daily.date)
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on storage_terabytes_daily.date = daily_rates.date
and daily_rates.service_type = 'STORAGE'
and daily_rates.usage_type = 'storage'
Expand All @@ -100,7 +100,7 @@ data_transfer_spend_hourly as (
spend 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
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 = 'data transfer'
and hours.hour::date = stg_usage_in_currency_daily.usage_date
Expand All @@ -122,11 +122,11 @@ compute_spend_hourly as (
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
left join {{ ref('stg_metering_history') }} as stg_metering_history on
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'compute'
Expand All @@ -151,9 +151,9 @@ serverless_task_spend_hourly as (
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_serverless_task_history') }} AS stg_serverless_task_history on
left join {{ ref('stg_serverless_task_history') }} as stg_serverless_task_history on
hours.hour = date_trunc('hour', stg_serverless_task_history.start_time)
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'serverless tasks'
Expand All @@ -176,9 +176,9 @@ adj_for_incl_cloud_services_hourly as (
0 as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_daily_history') }} AS stg_metering_daily_history on
left join {{ ref('stg_metering_daily_history') }} as stg_metering_daily_history on
hours.hour = stg_metering_daily_history.date
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'cloud services'
Expand Down Expand Up @@ -241,7 +241,7 @@ cloud_services_spend_hourly as (
from _cloud_services_usage_hourly
inner join _cloud_services_billed_daily on
_cloud_services_usage_hourly.date = _cloud_services_billed_daily.date
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on _cloud_services_usage_hourly.date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'cloud services'
Expand All @@ -264,12 +264,12 @@ automatic_clustering_spend_hourly as (
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
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 = 'AUTO_CLUSTERING'
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'automatic clustering'
Expand All @@ -292,12 +292,12 @@ materialized_view_spend_hourly as (
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
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
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'materialized views'
Expand All @@ -320,12 +320,12 @@ snowpipe_spend_hourly as (
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
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 = 'PIPE'
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'snowpipe'
Expand All @@ -348,12 +348,12 @@ snowpipe_streaming_spend_hourly as (
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
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 = 'SNOWPIPE_STREAMING'
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'snowpipe streaming'
Expand All @@ -376,12 +376,12 @@ query_acceleration_spend_hourly as (
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
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 = 'QUERY_ACCELERATION'
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'query acceleration'
Expand All @@ -404,12 +404,12 @@ replication_spend_hourly as (
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
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 = 'REPLICATION'
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'replication'
Expand All @@ -432,12 +432,12 @@ search_optimization_spend_hourly as (
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
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 = 'SEARCH_OPTIMIZATION'
left join {{ ref('daily_rates') }} AS daily_rates
left join {{ ref('daily_rates') }} as daily_rates
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'search optimization'
Expand Down

0 comments on commit 82dfe94

Please sign in to comment.