-
Notifications
You must be signed in to change notification settings - Fork 1
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
Data Quality Daily Row Check Mart Model #416
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2d9ac84
Created a data quality data model that returns daily row counts for d…
kengodleskidot b703f8a
updated column name for clarity
kengodleskidot 72e598a
updated comments
kengodleskidot b003c16
Merge branch 'main' of https://github.com/cagov/caldata-mdsa-caltrans…
kengodleskidot 693be6d
created a yml file for the mart quality folder and updated the dbt_pr…
kengodleskidot b628c05
updated data model to compare HV and ML stations along with all stati…
kengodleskidot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,36 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: quality__row_count_summary | ||
description: | | ||
This model counts the number of ML and HV detectors across multiple models on a daily basis | ||
to ensure that the detector count is consistent between all of the models. The models | ||
where detector counts are being evaluated are: | ||
- int_diagnostics__detector_status model | ||
- int_clearinghouse__detector_agg_five_minutes_with_missing_rows | ||
- int_imputation__detector_imputed_agg_five_minutes | ||
- int_performance__detector_metrics_agg_five_minutes | ||
The daily detector counts for these models should match. As an additional aggregation | ||
the number of good, bad, and total detectors is calculated in this model as well to monitor | ||
for any changes that should be investigated. The number of detectors and their health | ||
should not vary drastically between days so this model can help identify anamolies. | ||
columns: | ||
- name: SAMPLE_DATE | ||
description: | | ||
The date associated with the aggregate counts down in the 5 models to be compared. | ||
- name: ML_HV_DETECTOR_STATUS_TOTAL_COUNT | ||
description: Counts the number of distinct ML and HV detectors on a daily basis | ||
- name: ML_HV_CLEARINGHOUSE_DETECTOR_COUNT | ||
description: Counts the number of distinct ML and HV detectors on a daily basis | ||
- name: ML_HV_IMPUTATION_DETECTOR_COUNT | ||
description: Counts the number of distinct ML and HV detectors on a daily basis | ||
- name: ML_HV_PERFORMANCE_DETECTOR_COUNT | ||
description: Counts the number of distinct ML and HV detectors on a daily basis | ||
- name: GOOD_STATUS_COUNT | ||
description: | | ||
Counts the total number of detectors with a status of Good on a daily basis. | ||
- name: BAD_STATUS_COUNT | ||
description: | | ||
Counts the total number of detectors with a status other than Good on a daily basis. | ||
- name: ALL_DETECTOR_STATUS_TOTAL_COUNT | ||
description: Counts the total number of rows/detectors on a daily basis |
80 changes: 80 additions & 0 deletions
80
transform/models/marts/quality/quality__row_count_summary.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,80 @@ | ||
with | ||
|
||
ML_HV_DETECTOR_STATUS_DAILY_COUNT as ( | ||
/* | ||
* This CTE returns the number of total rows created daily in | ||
* the int_diagnostics__detector_status model. This count should be | ||
* to checked against the daily detector counts for the following models: | ||
* - int_clearinghouse__detector_agg_five_minutes_with_missing_rows | ||
* - int_imputation__detector_imputed_agg_five_minutes | ||
* - int_performance__detector_metrics_agg_five_minutes | ||
* The daily detector counts for these models should match for | ||
*/ | ||
select | ||
SAMPLE_DATE, | ||
count(*) as ML_HV_DETECTOR_STATUS_TOTAL_COUNT | ||
from {{ ref('int_diagnostics__detector_status') }} | ||
where STATION_TYPE = 'ML' or STATION_TYPE = 'HV' | ||
group by SAMPLE_DATE | ||
), | ||
|
||
-- Clearinghouse Detector Count per Day | ||
ML_HV_CLEARINGHOUSE_DETECTOR_DAILY_COUNT as ( | ||
select | ||
SAMPLE_DATE, | ||
count(distinct DETECTOR_ID) as ML_HV_CLEARINGHOUSE_DETECTOR_COUNT | ||
from {{ ref('int_clearinghouse__detector_agg_five_minutes_with_missing_rows') }} | ||
where STATION_TYPE = 'ML' or STATION_TYPE = 'HV' | ||
group by SAMPLE_DATE | ||
), | ||
|
||
-- Imputation Detector Count per Day | ||
ML_HV_IMPUTATION_DETECTOR_DAILY_COUNT as ( | ||
select | ||
SAMPLE_DATE, | ||
count(distinct DETECTOR_ID) as ML_HV_IMPUTATION_DETECTOR_COUNT | ||
from {{ ref('int_imputation__detector_imputed_agg_five_minutes') }} | ||
group by SAMPLE_DATE | ||
), | ||
|
||
-- Performance Detector Count per Day | ||
ML_HV_PERFORMANCE_DETECTOR_DAILY_COUNT as ( | ||
select | ||
SAMPLE_DATE, | ||
count(distinct DETECTOR_ID) as ML_HV_PERFORMANCE_DETECTOR_COUNT | ||
from {{ ref('int_performance__detector_metrics_agg_five_minutes') }} | ||
group by SAMPLE_DATE | ||
), | ||
|
||
-- Returns count for all station types per Day | ||
DETECTOR_STATUS_COUNT as ( | ||
select | ||
SAMPLE_DATE, | ||
count_if(STATUS = 'Good') as GOOD_STATUS_COUNT, | ||
count_if(STATUS != 'Good') as BAD_STATUS_COUNT, | ||
count(*) as ALL_DETECTOR_STATUS_TOTAL_COUNT | ||
from {{ ref('int_diagnostics__detector_status') }} | ||
group by SAMPLE_DATE | ||
), | ||
|
||
DAILY_DETECTOR_COUNT_CHECK as ( | ||
select | ||
MHDSDC.*, | ||
CDDC.ML_HV_CLEARINGHOUSE_DETECTOR_COUNT, | ||
IDDC.ML_HV_IMPUTATION_DETECTOR_COUNT, | ||
PDDC.ML_HV_PERFORMANCE_DETECTOR_COUNT, | ||
DSC.GOOD_STATUS_COUNT, | ||
DSC.BAD_STATUS_COUNT, | ||
DSC.ALL_DETECTOR_STATUS_TOTAL_COUNT | ||
from ML_HV_DETECTOR_STATUS_DAILY_COUNT as MHDSDC | ||
left join ML_HV_CLEARINGHOUSE_DETECTOR_DAILY_COUNT as CDDC | ||
on MHDSDC.SAMPLE_DATE = CDDC.SAMPLE_DATE | ||
left join ML_HV_IMPUTATION_DETECTOR_DAILY_COUNT as IDDC | ||
on MHDSDC.SAMPLE_DATE = IDDC.SAMPLE_DATE | ||
left join ML_HV_PERFORMANCE_DETECTOR_DAILY_COUNT as PDDC | ||
on MHDSDC.SAMPLE_DATE = PDDC.SAMPLE_DATE | ||
left join DETECTOR_STATUS_COUNT as DSC | ||
on MHDSDC.SAMPLE_DATE = DSC.SAMPLE_DATE | ||
) | ||
|
||
select * from DAILY_DETECTOR_COUNT_CHECK |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kengodleskidot , why the all GOOD_STATUS_COUNT is zero. Does that mean all detectors are down???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing that it will change once it will go through night job in production. Is that the case here?