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

fixes problems with quoting: true #139

Merged
merged 14 commits into from
Nov 30, 2023
2 changes: 1 addition & 1 deletion macros/create_merge_objects_udf.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro create_merge_objects_udf(relation) %}

create or replace function {{ relation.database }}.{{ relation.schema }}.merge_objects(obj1 variant, obj2 variant)
create or replace function {{ adapter.quote_as_configured(this.database, 'database') }}.{{ adapter.quote_as_configured(this.schema, 'schema') }}.merge_objects(obj1 variant, obj2 variant)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NiallRees can you have a look at this?

returns variant
language javascript
comment = 'Created by dbt-snowflake-monitoring dbt package.'
Expand Down
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 @@
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') }}
inner join {{ ref('daily_rates') }} daily_rates

Check failure on line 82 in models/cost_per_query.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
from all_queries
inner join credits_billed_daily
on date(all_queries.start_time) = credits_billed_daily.date
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 160 in models/cost_per_query.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
on date(all_queries.start_time) = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'cloud services'
Expand Down
56 changes: 28 additions & 28 deletions models/hourly_spend.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@
'Table and Time Travel' as storage_type,
database_name,
sum(average_database_bytes) / power(1024, 4) as storage_terabytes
from {{ ref('stg_database_storage_usage_history') }}
from {{ ref('stg_database_storage_usage_history') }} stg_database_storage_usage_history

Check failure on line 40 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.

Check failure on line 40 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL05: Alias 'stg_database_storage_usage_history' is never used in SELECT statement.
group by 1, 2, 3
union all
select
date,
'Failsafe' as storage_type,
database_name,
sum(average_failsafe_bytes) / power(1024, 4) as storage_terabytes
from {{ ref('stg_database_storage_usage_history') }}
from {{ ref('stg_database_storage_usage_history') }} stg_database_storage_usage_history

Check failure on line 48 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.

Check failure on line 48 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL05: Alias 'stg_database_storage_usage_history' is never used in SELECT statement.
group by 1, 2, 3
union all
select
date,
'Stage' as storage_type,
null as database_name,
sum(average_stage_bytes) / power(1024, 4) as storage_terabytes
from {{ ref('stg_stage_storage_usage_history') }}
from {{ ref('stg_stage_storage_usage_history') }} stg_stage_storage_usage_history

Check failure on line 56 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.

Check failure on line 56 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL05: Alias 'stg_stage_storage_usage_history' is never used in SELECT statement.
group by 1, 2, 3
),

Expand All @@ -77,7 +77,7 @@
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') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 80 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
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
left join {{ ref('stg_usage_in_currency_daily') }} stg_usage_in_currency_daily on

Check failure on line 103 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 125 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 129 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_serverless_task_history') }} on
left join {{ ref('stg_serverless_task_history') }} stg_serverless_task_history on

Check failure on line 154 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = date_trunc('hour', stg_serverless_task_history.start_time)
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 156 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
0 as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_daily_history') }} on
left join {{ ref('stg_metering_daily_history') }} stg_metering_daily_history on

Check failure on line 179 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = stg_metering_daily_history.date
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 181 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'cloud services'
Expand All @@ -201,7 +201,7 @@
sum(stg_metering_history.credits_used_cloud_services), 0
) as credits_used_cloud_services
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} STG_METERING_HISTORY on

Check failure on line 204 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.

Check failure on line 204 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL05: Alias 'STG_METERING_HISTORY' is never used in SELECT statement.

Check failure on line 204 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

CP02: Unquoted identifiers must be consistently lower case.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
Expand All @@ -216,7 +216,7 @@
sum(
credits_used_cloud_services + credits_adjustment_cloud_services
) as credits_used_cloud_services_billable
from {{ ref('stg_metering_daily_history') }}
from {{ ref('stg_metering_daily_history') }} stg_metering_daily_history

Check failure on line 219 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.

Check failure on line 219 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL05: Alias 'stg_metering_daily_history' is never used in SELECT statement.
where
service_type = 'WAREHOUSE_METERING'
group by 1
Expand All @@ -241,7 +241,7 @@
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') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 244 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 267 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'AUTO_CLUSTERING'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 272 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 295 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'MATERIALIZED_VIEW'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 300 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 323 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'PIPE'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 328 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 351 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'SNOWPIPE_STREAMING'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 356 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 379 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'QUERY_ACCELERATION'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 384 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 407 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'REPLICATION'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 412 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
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 @@
spend as spend_net_cloud_services,
any_value(daily_rates.currency) as currency
from hours
left join {{ ref('stg_metering_history') }} on
left join {{ ref('stg_metering_history') }} stg_metering_history on

Check failure on line 435 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
hours.hour = convert_timezone(
'UTC', stg_metering_history.start_time
)
and stg_metering_history.service_type = 'SEARCH_OPTIMIZATION'
left join {{ ref('daily_rates') }}
left join {{ ref('daily_rates') }} daily_rates

Check failure on line 440 in models/hourly_spend.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
on hours.hour::date = daily_rates.date
and daily_rates.service_type = 'COMPUTE'
and daily_rates.usage_type = 'search optimization'
Expand Down
Loading