Skip to content

DBT: Brazil Bol 2023 Gold

File location: s3://trase-storage/brazil/trade/bol/2023/gold/brazil_bol_2023_gold.parquet

DBT model name: brazil_bol_2023_gold

Explore on Metabase: Full table; summary statistics

Explore dependencies/lineage: link

Heads up — this asset has failing data tests

1 error. See the Data Tests tab below.


Description

Explore in Metabase here

Based on the cleaned version of Brazil BOL 2023 (brazil_bol_2023_silver), only including curated fields. Find where the fields come from and how they were cleaned in the fields documentation, and all the available source fields in silver version, and the vendor field glossary in google spreadsheets.


Details

Column Type Description
commodity VARCHAR Uppercase name of the commodity (BEEF, SOY, etc.) based on the hs4 code, and the list of commodities in the Trase reference table postgres_commodities
country_of_destination_economic_bloc VARCHAR The economic bloc (AfCFTA, ASEAN, EU, GCC, MERCOSUR, NAFTA, USMCA) the country of destination was a member of in the year of the record, according to main_economic_blocs, with its name in upper case (e.g. "EUROPEAN UNION", "MERCOSUR"); or the country of destination itself where it was in no bloc, so that the field is never null. A destination recorded as "EUROPEAN UNION" is in the European Union. This replaces the silver field of the same name, which only resolves the European Union.
country_of_destination_label VARCHAR Based on the Datamar source field PLACE_AND_PORTS_DEST_COUNTRY: "Country where the carrier delivered the cargo"
country_of_destination_name VARCHAR Official Trase country name where the export was delivered. It is cleaned based on country_of_destination_label field Note that European Union countries are not unified as 'EUROPEAN UNION' country, although the source BOL does has 768 records with the label "EUROPEAN" instead of a specific country.
country_of_destination_trase_id VARCHAR Official Trase country id, using the iso two letter country code based on the field country_of_destination_name
date DATE Based on the source field DATES_LONG_HAUL_YYYYMMDD: Berthing (arrival) date of the long haul vessel: Year, month and day
year INTEGER
month INTEGER
exporter_cnpj VARCHAR Based on the source field COMPANY_SHIPPER_REGISTRATION_NUMBER (the shipper is the exporter), which already only contains digits. The cleaning of this field uses stdnum.br python library to identify if its a valid cnpj, cpf, or unkown (and sets this in the exporter_type field). If its a valid cnpj it left pads with 0 until it reaches 14 characters, and if its a cpf left pads to 11 characters.
exporter_country_label VARCHAR Based on the source field PLACE_AND_PORTS_POL_COUNTRY: country name of the exporter
exporter_group VARCHAR Official Trase trader group name, taken from the trader reference database. First it checks the reference data based on the tax identification of the record, and then based on the exporter_label. As a trader can change its group affiliation in time, the group valid for the current BOL year is taken.
exporter_label VARCHAR Based on the source field COMPANY_SHIPPER_SHIPPER_NAME_DETAILED: Detailed Shipper (exporter) name.
exporter_municipality_label VARCHAR Based on the source field COMPANY_SHIPPER_CITY: Shipper (exporter) city
exporter_municipality_name VARCHAR Official Trase name of the municipality, based on the exporter_municipality_label, and cleaning it based on the postgres_regions reference table - where it checks the municipality exists and takes the official name
exporter_municipality_trase_id VARCHAR
exporter_name VARCHAR Official Trase trader name, taken from the trader reference database. First it checks the reference data based on the tax identification of the record, and then based on the exporter_label field
exporter_node_id BIGINT
exporter_state_label VARCHAR Based on the source field COMPANY_SHIPPER_STATE_NAME: Shipper (exporter) state name
exporter_state_name VARCHAR Official Trase name of the state, based on the exporter_state_label, and cleaning it based on the postgres_regions reference table - where it checks the state exists and takes the official name
exporter_state_trase_id VARCHAR
exporter_trase_id VARCHAR Official Trase trader id, taken from the trader reference database. First it checks the reference data based on the tax identification of the record, and then based on the exporter_label field. The trase id is built based on the tax number.
exporter_type VARCHAR Based on the field exporter_cnpj, it identifies if its a valid cnpj, cpf or if its of unknown type.
fob DOUBLE Based on the field fob_original, including imputing empty values based on COMTRADE or BOL average values for the hs6 code. Where imputed, the field fob_adjustment_type shows which kind of imputing was done.
fob_adjustment_type VARCHAR
fob_original DOUBLE Based on the source field MEASURES_SECEX_FOB. Though this field doesn't exist in the vendor glossary, there is a similar field in the glossary called MEASURES_FOB_VALUE_USD: Monthly average FOB value per commodity in US dollars.
hs4 VARCHAR
hs5 VARCHAR
hs6 VARCHAR
hs6_description VARCHAR
hs8 VARCHAR
importer_group VARCHAR
importer_label VARCHAR
importer_name VARCHAR
importer_node_id BIGINT
net_weight_kg DOUBLE Based on the source field MEASURES_WTKG: Weight in kilos
net_weight_tonnes DOUBLE Based on the source field MEASURES_WTMT: Weight in metric tonnes
port_of_export_label VARCHAR Based on the source field PLACE_AND_PORTS_POL_NAME: POL ‐ PORT OF LOADING ‐ Port where the LONG HAUL vessel loaded the cargo
port_of_export_name VARCHAR Official Trase port name where the cargo was loaded. It is cleaned based on port_of_export_label field and the postgres_ports reference table, checking also the port exists in the port_of_export_country
port_of_import_country_label VARCHAR Based on the source field PLACE_AND_PORTS_POD_COUNTRY: POD ‐ PORT OF DISCHARGE ‐ Country where the LONG HAUL vessel discharged the cargo
port_of_import_country_name VARCHAR
port_of_import_label VARCHAR Based on the source field PLACE_AND_PORTS_POD_NAME: POD ‐ PORT OF DISCHARGE ‐ Port where the LONG HAUL vessel discharged the cargo
port_of_import_name VARCHAR Official Trase port name where the cargo was discharged. If there is no current existing port with that name in the port_of_import_country, it returns a NULL. It is cleaned based on port_of_import_label field and the postgres_ports reference table.
mdic_bol_region_of_destination `` Destination country (country_of_destination_trase_id) mapped to a broad world region, used only to join the BOL dataset with MDIC/SECEX exports. ERROR - UNMAPPED would indicate a country missing from the shared crosswalk.
mdic_bol_port_group `` Export port (port_of_export_name) mapped to a named port group/complex, used only to join the BOL dataset with MDIC/SECEX exports. ERROR - UNMAPPED would indicate a port missing from the shared crosswalk.

Review full report including sample errors records if they exist (link)

Test column Test name Failing rows Last test run Last status Query in Metabase
Whole table test brazil_bol_2023_gold_exporter_cnpjs_exist_in_receita_federal — 2026-10-19 06:26 error 🔍 run query
Whole table test brazil_bol_2023_gold_exporters_exist_in_postgres_traders — 2026-10-19 06:13 pass 🔍 run query
Whole table test brazil_bol_2023_gold_has_gavilon_records — 2026-10-19 06:13 pass 🔍 run query
Whole table test brazil_bol_2023_gold_has_glencore_importadora_records — 2026-10-19 06:13 pass 🔍 run query
Whole table test brazil_bol_2023_gold_has_novaagri_records — 2026-10-19 06:13 pass 🔍 run query
Whole table test brazil_bol_2023_gold_importers_exist_in_postgres_traders — 2026-10-19 06:13 pass 🔍 run query
Whole table test dbt_expectations_expect_table_aggregation_to_equal_other_table_brazil_bol_2023_gold_source_source_brazil_original_brazil_soy_beef_bol_2023___count___0_03 — 2026-10-19 06:18 pass 🔍 run query
Whole table test dbt_utils_expression_is_true_brazil_bol_2023_gold_ABS_net_weight_kg_1_0_net_weight_tonnes_1000_5 — 2026-10-19 06:19 pass 🔍 run query
commodity not_null_brazil_bol_2023_gold_commodity — 2026-10-19 06:21 pass 🔍 run query
commodity relationships_brazil_bol_2023_gold_commodity__commodity__ref_postgres_commodities_ — 2026-10-19 06:23 pass 🔍 run query
country_of_destination_economic_bloc brazil_bol_2023_gold_economic_bloc_matches_main_economic_blocs — 2026-10-19 06:13 pass 🔍 run query
country_of_destination_economic_bloc not_null_brazil_bol_2023_gold_country_of_destination_economic_bloc — 2026-10-19 06:21 pass 🔍 run query
country_of_destination_name not_null_brazil_bol_2023_gold_country_of_destination_name — 2026-10-19 06:21 pass 🔍 run query
country_of_destination_name relationships_brazil_bol_2023_gold_country_of_destination_name__country_name__ref_postgres_countries_ — 2026-10-19 06:23 pass 🔍 run query
country_of_destination_trase_id not_null_brazil_bol_2023_gold_country_of_destination_trase_id — 2026-10-19 06:21 pass 🔍 run query
country_of_destination_trase_id relationships_brazil_bol_2023_gold_country_of_destination_trase_id__country_trase_id__ref_postgres_countries_ — 2026-10-19 06:23 pass 🔍 run query
date dbt_utils_accepted_range_brazil_bol_2023_gold_date__CAST_2023_12_31_AS_DATE___CAST_2023_01_01_AS_DATE_ — 2026-10-19 06:18 pass 🔍 run query
exporter_cnpj not_null_brazil_bol_2023_gold_exporter_cnpj — 2026-10-19 06:21 pass 🔍 run query
exporter_country_label accepted_values_brazil_bol_2023_gold_exporter_country_label__BRAZIL — 2026-10-19 06:12 pass 🔍 run query
exporter_country_label not_null_brazil_bol_2023_gold_exporter_country_label — 2026-10-19 06:21 pass 🔍 run query
exporter_group brazil_bol_2023_gold_exporter_group_matches_postgres_traders — 2026-10-19 06:13 pass 🔍 run query
exporter_group brazil_bol_2023_gold_exporters_not_in_former_groups — 2026-10-19 06:13 pass 🔍 run query
exporter_group brazil_bol_2023_gold_novaagri_exporters_are_toyota_tsusho — 2026-10-19 06:13 pass 🔍 run query
exporter_group brazil_bol_2023_gold_viterra_family_exporters_are_glencore — 2026-10-19 06:13 pass 🔍 run query
exporter_group not_null_brazil_bol_2023_gold_exporter_group — 2026-10-19 06:21 pass 🔍 run query
exporter_label not_null_brazil_bol_2023_gold_exporter_label — 2026-10-19 06:21 pass 🔍 run query
exporter_municipality_label dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_municipality_label — 2026-10-19 06:19 pass 🔍 run query
exporter_municipality_name dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_municipality_name — 2026-10-19 06:19 pass 🔍 run query
exporter_municipality_name dbt_utils_relationships_where_brazil_bol_2023_gold_exporter_municipality_name__name__ref_postgres_regions_without_geometry___level_6_AND_country_BRAZIL_ — 2026-10-19 06:19 pass 🔍 run query
exporter_municipality_trase_id brazil_bol_2023_gold_exporter_municipality_trase_id_in_ibge_municipalities_2023 — 2026-10-19 06:13 pass 🔍 run query
exporter_municipality_trase_id dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_municipality_trase_id — 2026-10-19 06:19 pass 🔍 run query
exporter_municipality_trase_id dbt_utils_relationships_where_brazil_bol_2023_gold_exporter_municipality_trase_id__trase_id__ref_postgres_regions_without_geometry___level_6_AND_country_BRAZIL_ — 2026-10-19 06:19 pass 🔍 run query
exporter_name brazil_bol_2023_gold_glencore_agriculture_exporter_is_viterra — 2026-10-19 06:13 pass 🔍 run query
exporter_name brazil_bol_2023_gold_glencore_do_brasil_exporter_name — 2026-10-19 06:13 pass 🔍 run query
exporter_name brazil_bol_2023_gold_glencore_importadora_exporter_name — 2026-10-19 06:13 pass 🔍 run query
exporter_name not_null_brazil_bol_2023_gold_exporter_name — 2026-10-19 06:21 pass 🔍 run query
exporter_name relationships_brazil_bol_2023_gold_exporter_name__name__ref_postgres_traders_ — 2026-10-19 06:24 pass 🔍 run query
exporter_node_id not_null_brazil_bol_2023_gold_exporter_node_id — 2026-10-19 06:21 pass 🔍 run query
exporter_node_id relationships_brazil_bol_2023_gold_exporter_node_id__trader_node_id__ref_postgres_traders_ — 2026-10-19 06:24 pass 🔍 run query
exporter_state_label dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_state_label — 2026-10-19 06:19 pass 🔍 run query
exporter_state_name dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_state_name — 2026-10-19 06:19 pass 🔍 run query
exporter_state_name dbt_utils_relationships_where_brazil_bol_2023_gold_exporter_state_name__name__ref_postgres_regions_without_geometry___level_3_AND_country_BRAZIL_ — 2026-10-19 06:19 pass 🔍 run query
exporter_state_trase_id brazil_bol_2023_gold_exporter_state_trase_id_in_ibge_states_2023 — 2026-10-19 06:13 pass 🔍 run query
exporter_state_trase_id dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_state_trase_id — 2026-10-19 06:19 pass 🔍 run query
exporter_state_trase_id dbt_utils_relationships_where_brazil_bol_2023_gold_exporter_state_trase_id__trase_id__ref_postgres_regions_without_geometry___level_3_AND_country_BRAZIL_ — 2026-10-19 06:19 pass 🔍 run query
exporter_trase_id dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_99__exporter_trase_id — 2026-10-19 06:19 pass 🔍 run query
exporter_trase_id relationships_brazil_bol_2023_gold_exporter_trase_id__trase_id__ref_postgres_traders_ — 2026-10-19 06:24 pass 🔍 run query
exporter_type accepted_values_brazil_bol_2023_gold_exporter_type__cnpj__cpf__unknown — 2026-10-19 06:12 pass 🔍 run query
exporter_type not_null_brazil_bol_2023_gold_exporter_type — 2026-10-19 06:21 pass 🔍 run query
fob dbt_utils_accepted_range_brazil_bol_2023_gold_fob__700000000__0_01 — 2026-10-19 06:18 pass 🔍 run query
fob not_null_brazil_bol_2023_gold_fob — 2026-10-19 06:21 pass 🔍 run query
hs4 not_null_brazil_bol_2023_gold_hs4 — 2026-10-19 06:21 pass 🔍 run query
hs4 relationships_brazil_bol_2023_gold_hs4__code__ref_hs2017_ — 2026-10-19 06:24 pass 🔍 run query
importer_group brazil_bol_2023_gold_importer_group_matches_postgres_traders — 2026-10-19 06:13 pass 🔍 run query
importer_group brazil_bol_2023_gold_importers_not_in_former_groups — 2026-10-19 06:13 pass 🔍 run query
importer_group brazil_bol_2023_gold_novaagri_importers_are_toyota_tsusho — 2026-10-19 06:13 pass 🔍 run query
importer_group brazil_bol_2023_gold_viterra_family_importers_are_glencore — 2026-10-19 06:13 pass 🔍 run query
importer_name brazil_bol_2023_gold_glencore_agriculture_importer_is_viterra — 2026-10-19 06:13 pass 🔍 run query
importer_name relationships_brazil_bol_2023_gold_importer_name__name__ref_postgres_traders_ — 2026-10-19 06:24 pass 🔍 run query
importer_node_id relationships_brazil_bol_2023_gold_importer_node_id__trader_node_id__ref_postgres_traders_ — 2026-10-19 06:24 pass 🔍 run query
mdic_bol_port_group dbt_expectations_expect_column_unique_value_count_to_be_between_brazil_bol_2023_gold_mdic_bol_port_group__40__1 — 2026-10-19 06:17 pass 🔍 run query
mdic_bol_port_group dbt_utils_expression_is_true_brazil_bol_2023_gold_mdic_bol_port_group___ERROR_UNMAPPED_ — 2026-10-19 06:19 pass 🔍 run query
mdic_bol_port_group not_null_brazil_bol_2023_gold_mdic_bol_port_group — 2026-10-19 06:21 pass 🔍 run query
mdic_bol_region_of_destination dbt_expectations_expect_column_unique_value_count_to_be_between_brazil_bol_2023_gold_mdic_bol_region_of_destination__10__1 — 2026-10-19 06:17 pass 🔍 run query
mdic_bol_region_of_destination dbt_utils_expression_is_true_brazil_bol_2023_gold_mdic_bol_region_of_destination___ERROR_UNMAPPED_ — 2026-10-19 06:19 pass 🔍 run query
mdic_bol_region_of_destination not_null_brazil_bol_2023_gold_mdic_bol_region_of_destination — 2026-10-19 06:21 pass 🔍 run query
net_weight_kg dbt_utils_accepted_range_brazil_bol_2023_gold_net_weight_kg__True__120000000__1 — 2026-10-19 06:18 pass 🔍 run query
net_weight_kg not_null_brazil_bol_2023_gold_net_weight_kg — 2026-10-19 06:21 pass 🔍 run query
net_weight_tonnes dbt_utils_accepted_range_brazil_bol_2023_gold_net_weight_tonnes__100000000__0_0001 — 2026-10-19 06:18 pass 🔍 run query
net_weight_tonnes not_null_brazil_bol_2023_gold_net_weight_tonnes — 2026-10-19 06:21 pass 🔍 run query
port_of_export_label not_null_brazil_bol_2023_gold_port_of_export_label — 2026-10-19 06:21 pass 🔍 run query
port_of_export_name not_null_brazil_bol_2023_gold_port_of_export_name — 2026-10-19 06:21 pass 🔍 run query
port_of_export_name relationships_brazil_bol_2023_gold_port_of_export_name__name__ref_postgres_ports_ — 2026-10-19 06:24 pass 🔍 run query
port_of_import_country_label not_null_brazil_bol_2023_gold_port_of_import_country_label — 2026-10-19 06:21 pass 🔍 run query
port_of_import_country_name relationships_brazil_bol_2023_gold_port_of_import_country_name__country_name__ref_postgres_countries_ — 2026-10-19 06:24 pass 🔍 run query
port_of_import_label not_null_brazil_bol_2023_gold_port_of_import_label — 2026-10-19 06:21 pass 🔍 run query
port_of_import_name dbt_utils_not_null_proportion_brazil_bol_2023_gold_0_8__port_of_import_name — 2026-10-19 06:19 pass 🔍 run query
port_of_import_name relationships_brazil_bol_2023_gold_port_of_import_name__name__ref_postgres_ports_ — 2026-10-19 06:24 pass 🔍 run query

Models

Exposures

Models

No called script or script source not found.

"""Brazil BOL 2023 Gold

Curated subset of `brazil_bol_2023_silver`, with the economic bloc of the destination resolved
against `main_economic_blocs`, plus the two MDIC-matching columns. The column list
and mapping logic are shared across years in `trase/data/brazil/trade/bol/bol_gold.py`.
"""

from trase.data.brazil.trade.bol.bol_gold import build_gold


def model(dbt, cursor):
    dbt.config(materialized="external")
    return build_gold(
        dbt.ref("brazil_bol_2023_silver").pl().lazy(),
        dbt.ref("main_economic_blocs").pl().lazy(),
    )