Skip to content

Commit

Permalink
Merge pull request #142 from get-select/switch_to_table
Browse files Browse the repository at this point in the history
Switch metering_history to table materialization
  • Loading branch information
NiallRees authored Jan 15, 2024
2 parents b69f913 + 24979f0 commit c7ce05c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .changes/5.0.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## dbt-snowflake-monitoring 5.0.1 - January 15, 2024

### Fixes

- Switch stg_metering_history to a table incrementalization to handle natural dupes ([#142](https://github.com/get-select/dbt-snowflake-monitoring/pull/142))


10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).

## dbt-snowflake-monitoring 5.0.1 - January 15, 2024

### Fixes

- Switch stg_metering_history to a table incrementalization to handle natural dupes ([#142](https://github.com/get-select/dbt-snowflake-monitoring/pull/142))



## dbt-snowflake-monitoring 5.0.0 - January 14, 2024

### Features
Expand All @@ -24,8 +32,6 @@ To upgrade from 4.x.x, you'll need to full refresh the `stg_metering_history` mo

### Contributors
- [@ernestoongaro](https://github.com/ernestoongaro) (Fixes)


## dbt-snowflake-monitoring 4.6.0 - November 09, 2023

### Features
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'dbt_snowflake_monitoring'
version: '5.0.0'
version: '5.0.1'
config-version: 2

profile: dbt_snowflake_monitoring
Expand Down
9 changes: 1 addition & 8 deletions models/staging/stg_metering_history.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{ config(
materialized='incremental',
unique_key=['service_type', 'start_time', 'entity_id'],
materialized='table'
) }}

select
Expand All @@ -13,10 +12,4 @@ select
credits_used_cloud_services,
credits_used
from {{ source('snowflake_account_usage', 'metering_history') }}

{% if is_incremental() %}
-- account for changing metering data
where end_time > (select coalesce(dateadd(day, -7, max(end_time)), '1970-01-01') from {{ this }})
{% endif %}

order by start_time asc

0 comments on commit c7ce05c

Please sign in to comment.