DBT Test: Check Id Palm Unrefined Indonesia Palm Oil Sei Pcs V1 3 Seipcs 2021
DBT test name: check_id_palm_unrefined_indonesia_palm_oil_sei_pcs_v1_3_seipcs_2021_
DBT details
-
Kind:
generic(check_id_palm_unrefined) -
Test file: trase/data_pipeline/models/indonesia/palm_oil/sei_pcs/v1_3/_schema.yml
Description
No description
Details
{{ test_check_id_palm_unrefined(**_dbt_generic_test_kwargs) }}{{ config(alias="check_id_palm_unrefined_indone_4bf55fc6d86eb64cc504b91dc6b4c22c") }}
/*
* This test fails if any unrefined flows of Indonesia palm oil do not have the correct
* values. For speed the test will return only return a single row for each test with a
* placeholder value.
*/
/* ------------------------------------------------------------------------------------
Our first test is that the commodity column contains the value CPO at least once
TODO - could run this test once per year?
------------------------------------------------------------------------------------- */
select 'no such commodity=CPO' as error
where not exists (
select 1
from "memory"."main"."indonesia_palm_oil_sei_pcs_v1_3_seipcs_2021"
where commodity = 'CPO'
)
/* ------------------------------------------------------------------------------------
Our second test is that the refinery etc. have specific values if and only if the
commodity is CPO
------------------------------------------------------------------------------------- */
union all
(
select 'some columns have incorrect values' as error
from "memory"."main"."indonesia_palm_oil_sei_pcs_v1_3_seipcs_2021"
where
-- the below rules do not apply to UNKNOWN COUNTRY flows
country <> 'UNKNOWN'
--
and not (
((commodity = 'CPO') = ( refinery = 'NOT REFINED')) and
((commodity = 'CPO') = ( refinery_group = 'NOT REFINED')) and
((commodity = 'CPO') = (refinery_trase_id = 'ID-PALM-REFINERY-0000'))
)
)