-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to fix timeseries model by materializing more intermediates (#…
- Loading branch information
Showing
3 changed files
with
73 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ntermediate/metrics/timeseries/int_timeseries_code_metrics_by_artifact_developer_days.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{{ | ||
config( | ||
materialized='table' | ||
) | ||
}} | ||
|
||
{% set fulltime_dev_days = 10 %} | ||
|
||
with to_artifact_start_dates as ( | ||
select | ||
to_artifact_id, | ||
event_source, | ||
MIN(bucket_day) as first_commit_date | ||
from {{ ref("int_timeseries_code_metrics_commits") }} | ||
group by | ||
to_artifact_id, | ||
event_source | ||
), | ||
|
||
calendar as ( | ||
select | ||
to_artifact_id, | ||
event_source, | ||
TIMESTAMP_ADD(first_commit_date, interval day_offset day) as bucket_day | ||
from | ||
to_artifact_start_dates, | ||
UNNEST( | ||
GENERATE_ARRAY( | ||
0, | ||
TIMESTAMP_DIFF( | ||
(select MAX(bucket_day) as last_commit_date from commits), | ||
first_commit_date, day | ||
) | ||
) | ||
) as day_offset | ||
), | ||
|
||
devs as ( | ||
select distinct developer_id | ||
from {{ ref("int_timeseries_code_metrics_commits") }} | ||
), | ||
|
||
select | ||
devs.developer_id, | ||
calendar.to_artifact_id, | ||
calendar.bucket_day, | ||
calendar.event_source | ||
from calendar | ||
cross join devs |
19 changes: 19 additions & 0 deletions
19
warehouse/dbt/models/intermediate/metrics/timeseries/int_timeseries_code_metrics_commits.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{ | ||
config( | ||
materialized='ephemeral' | ||
) | ||
}} | ||
|
||
select | ||
from_artifact_id as developer_id, | ||
to_artifact_id, | ||
event_source, | ||
bucket_day, | ||
CAST(SUM(amount) > 0 as int64) as commit_count | ||
from {{ ref('int_events_daily_to_artifact') }} | ||
where event_type = 'COMMIT_CODE' | ||
group by | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source, | ||
bucket_day |