-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
257 additions
and
417 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
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
{% test accepted_values_valor_penalidade(model) -%} | ||
{% test accepted_values_in_table(model, column_name, ref_table, ref_column) %} | ||
WITH | ||
all_values AS ( | ||
SELECT | ||
DISTINCT valor_penalidade AS value_field, | ||
DISTINCT {{ column_name }} AS value_field, | ||
COUNT(*) AS n_records | ||
FROM | ||
{{ model }} | ||
WHERE | ||
DATA BETWEEN DATE("{{ var('start_date') }}") | ||
AND DATE("{{ var('end_date') }}") | ||
DATA BETWEEN DATE("{{ var('date_range_start') }}") | ||
AND DATE("{{ var('date_range_end') }}") | ||
GROUP BY | ||
valor_penalidade ) | ||
{{ column_name }} | ||
) | ||
SELECT | ||
* | ||
FROM | ||
all_values | ||
WHERE | ||
value_field NOT IN ( | ||
SELECT | ||
valor | ||
{{ ref_column }} | ||
FROM | ||
-- `rj-smtr`.`dashboard_subsidio_sppo`.`valor_tipo_penalidade` | ||
{{ ref('valor_tipo_penalidade') }} | ||
) | ||
{{ ref(ref_table) }} | ||
) | ||
{%- endtest %} |
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
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 |
---|---|---|
@@ -1,79 +1,21 @@ | ||
{% test check_sppo_veiculo_dia(model) %} | ||
WITH | ||
count_dist_status AS ( | ||
WITH | ||
count_dist_status AS ( | ||
SELECT | ||
DATA, | ||
COUNT(DISTINCT status) AS q_dist_status, | ||
FROM | ||
-- rj-smtr.veiculo.sppo_veiculo_dia | ||
{{ ref('sppo_veiculo_dia')}} | ||
WHERE | ||
DATA BETWEEN DATE("{{ var('date_range_start') }}") | ||
AND DATE("{{ var('end_date') }}") | ||
GROUP BY | ||
1 | ||
HAVING | ||
COUNT(DISTINCT status) = 1 ) | ||
SELECT | ||
DATA, | ||
COUNT(DISTINCT status) AS q_dist_status, | ||
NULL AS q_duplicated_status, | ||
NULL AS q_null_status | ||
* | ||
FROM | ||
-- rj-smtr.veiculo.sppo_veiculo_dia | ||
{{ ref('sppo_veiculo_dia')}} | ||
WHERE | ||
DATA BETWEEN DATE("{{ var('start_date') }}") | ||
AND DATE("{{ var('end_date') }}") | ||
GROUP BY | ||
1 | ||
HAVING | ||
COUNT(DISTINCT status) = 1 ), | ||
count_duplicated_status AS ( | ||
SELECT | ||
DATA, | ||
id_veiculo, | ||
COUNT(*) AS q_status, | ||
FROM | ||
-- rj-smtr.veiculo.sppo_veiculo_dia | ||
{{ ref('sppo_veiculo_dia')}} | ||
WHERE | ||
DATA BETWEEN DATE("{{ var('start_date') }}") | ||
AND DATE("{{ var('end_date') }}") | ||
GROUP BY | ||
1, | ||
2 | ||
HAVING | ||
COUNT(*) > 1 ), | ||
count_duplicated_status_agg AS ( | ||
SELECT | ||
DATA, | ||
NULL AS q_dist_status, | ||
SUM(q_status) AS q_duplicated_status, | ||
NULL AS q_null_status | ||
FROM | ||
count_duplicated_status | ||
GROUP BY | ||
1), | ||
count_null_status AS ( | ||
SELECT | ||
DATA, | ||
NULL AS q_dist_status, | ||
NULL AS q_duplicated_status, | ||
COUNT(*) AS q_null_status | ||
FROM | ||
-- rj-smtr.veiculo.sppo_veiculo_dia | ||
{{ ref('sppo_veiculo_dia')}} | ||
WHERE | ||
DATA BETWEEN DATE("{{ var('start_date') }}") | ||
AND DATE("{{ var('end_date') }}") | ||
AND status IS NULL | ||
GROUP BY | ||
1 ) | ||
SELECT | ||
* | ||
FROM | ||
count_dist_status | ||
|
||
UNION ALL | ||
|
||
SELECT | ||
* | ||
FROM | ||
count_duplicated_status_agg | ||
|
||
UNION ALL | ||
|
||
SELECT | ||
* | ||
FROM | ||
count_null_status | ||
|
||
count_dist_status | ||
{% endtest %} |
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
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 was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.