DBT Test: Check Id Palm Domestic Seipcs Indonesia Palm Oil 2022 Km 0 Mgd 30 Patched
DBT test name: check_id_palm_domestic_seipcs_indonesia_palm_oil_2022_km_0_mgd_30_patched_
DBT details
-
Kind:
generic(check_id_palm_domestic) -
Test file: trase/data_pipeline/models/indonesia/palm_oil/sei_pcs/_schema.yml
Description
No description
Details
{{ test_check_id_palm_domestic(**_dbt_generic_test_kwargs) }}{{ config(alias="check_id_palm_domestic_seipcs__c8720606a92731c147a5abacbb06369f") }}
/*
* This test fails if any domestic 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 'key' column contains the value DOMESTIC at least once
TODO - could run this test once per year?
------------------------------------------------------------------------------------- */
select 'no such key=DOMESTIC' as error
where not exists (
select 1
from "trase_production"."main_indonesia_palm"."seipcs_indonesia_palm_oil_2022_km_0_mgd_30_patched"
where key = 'DOMESTIC'
)
/* ------------------------------------------------------------------------------------
Our second test is that the exporter etc. have specific values if and only if the key is
'DOMESTIC'
------------------------------------------------------------------------------------- */
union all
(
select 'some columns have incorrect values' as error
from "trase_production"."main_indonesia_palm"."seipcs_indonesia_palm_oil_2022_km_0_mgd_30_patched"
where not (
((key = 'DOMESTIC') = ( exporter = 'DOMESTIC PROCESSING AND CONSUMPTION')) and
((key = 'DOMESTIC') = ( exporter_group = 'DOMESTIC PROCESSING AND CONSUMPTION')) and
((key = 'DOMESTIC') = ( importer = 'DOMESTIC PROCESSING AND CONSUMPTION')) and
((key = 'DOMESTIC') = ( importer_group = 'DOMESTIC PROCESSING AND CONSUMPTION')) and
((key = 'DOMESTIC') = ( importer_group = 'DOMESTIC PROCESSING AND CONSUMPTION')) and
((key = 'DOMESTIC') = ( port_trase_id = 'ID-PORT-DOMESTIC'))
)
limit 1
)
/* ------------------------------------------------------------------------------------
Our third test is that domestic flows are always unrefined palm oil
------------------------------------------------------------------------------------- */
union all
(
select 'some flows are not unrefined palm oil' as error
from "trase_production"."main_indonesia_palm"."seipcs_indonesia_palm_oil_2022_km_0_mgd_30_patched"
where key = 'DOMESTIC' and not (
commodity = 'CPO'
)
limit 1
)
/* ------------------------------------------------------------------------------------
Our fourth test is that domestic flows are always unknown mill
------------------------------------------------------------------------------------- */
union all
(
select 'some flows are not unrefined palm oil' as error
from "trase_production"."main_indonesia_palm"."seipcs_indonesia_palm_oil_2022_km_0_mgd_30_patched"
where key = 'DOMESTIC' and not (
mill = 'UNKNOWN' and
mill_group = 'UNKNOWN'
)
limit 1
)