From 8c338947b45d1e0c8e8aaf1f52a231eaa12affee Mon Sep 17 00:00:00 2001 From: folhesgabriel Date: Wed, 24 Apr 2024 15:15:12 -0300 Subject: [PATCH 1/3] feat: add br_me_comex_stat schema, models and macro --- macros/transform_mdic_country_code.sql | 297 ++++++++++++++++++ ...br_me_comex_stat__municipio_exportacao.sql | 28 +- ...br_me_comex_stat__municipio_importacao.sql | 21 +- .../br_me_comex_stat__ncm_exportacao.sql | 16 +- .../br_me_comex_stat__ncm_importacao.sql | 14 +- models/br_me_comex_stat/schema.yml | 117 ++++++- 6 files changed, 449 insertions(+), 44 deletions(-) create mode 100644 macros/transform_mdic_country_code.sql diff --git a/macros/transform_mdic_country_code.sql b/macros/transform_mdic_country_code.sql new file mode 100644 index 00000000..d6d0602e --- /dev/null +++ b/macros/transform_mdic_country_code.sql @@ -0,0 +1,297 @@ +{% macro transform_mdic_country_code(column_name) %} + -- mdic stands for: Ministério do Desenvolvimento, Indústria, Comércio e Serviços + -- it has its own country ids that can be found here: + -- https://balanca.economia.gov.br/balanca/bd/tabelas/PAIS.csv + -- NOTE: + -- '' values were set beacause the original matches were ZZZ which + -- indicates the inexistance of the code + case + {% for old_code, new_code in [ + (0, null), + (13, "AFG"), + (15, "ALA"), + (17, "ALB"), + (20, "ESP"), + (23, "DEU"), + (25, "DEU"), + (31, "BFA"), + (37, "AND"), + (40, "AGO"), + (41, "AIA"), + (42, "ATA"), + (43, "ATG"), + (47, "ANT"), + (53, "SAU"), + (59, "DZA"), + (63, "ARG"), + (64, "ARM"), + (65, "ABW"), + (69, "AUS"), + (72, "AUT"), + (73, "AZE"), + (77, "BHS"), + (80, "BHR"), + (81, "BGD"), + (83, "BRB"), + (85, "BLR"), + (87, "BEL"), + (88, "BLZ"), + (90, "BMU"), + (93, "MMR"), + (97, "BOL"), + (98, "BIH"), + (99, "BES"), + (100, "BRA"), + (101, "BWA"), + (102, "BVT"), + (105, "BRA"), + (108, "BRN"), + (111, "BGR"), + (115, "BDI"), + (119, "BTN"), + (127, "CPV"), + (137, "CYM"), + (141, "KHM"), + (145, "CMR"), + (149, "CAN"), + (150, "GGY"), + (151, "ESP"), + (152, "GBR"), + (153, "KAZ"), + (154, "QAT"), + (158, "CHL"), + (160, "CHN"), + (161, "TWN"), + (163, "CYP"), + (165, "CCK"), + (169, "COL"), + (173, "COM"), + (177, "COG"), + (183, "COK"), + (187, "PRK"), + (190, "KOR"), + (193, "CIV"), + (195, "HRV"), + (196, "CRI"), + (198, "KWT"), + (199, "CUB"), + (200, "CUW"), + (229, "BEN"), + (232, "DNK"), + (235, "DMA"), + (237, "ARE"), + (239, "ECU"), + (240, "EGY"), + (243, "ERI"), + (244, "ARE"), + (245, "ESP"), + (246, "SVN"), + (247, "SVK"), + (249, "USA"), + (251, "EST"), + (253, "ETH"), + (255, "FLK"), + (259, "FRO"), + (267, "PHL"), + (271, "FIN"), + (275, "FRA"), + (281, "GAB"), + (285, "GMB"), + (289, "GHA"), + (291, "GEO"), + (292, "SGS"), + (293, "GIB"), + (297, "GRD"), + (301, "GRC"), + (305, "GRL"), + (309, "GLP"), + (313, "GUM"), + (317, "GTM"), + (321, "GGY"), + (325, "GUF"), + (329, "GIN"), + (331, "GNQ"), + (334, "GNB"), + (337, "GUY"), + (341, "HTI"), + (343, "HMD"), + (345, "HND"), + (351, "HKG"), + (355, "HUN"), + (357, "YEM"), + (358, "YMD"), + (359, "IMN"), + (361, "IND"), + (365, "IDN"), + (367, "GBR"), + (369, "IRQ"), + (372, "IRN"), + (375, "IRL"), + (379, "ISL"), + (383, "ISR"), + (386, "ITA"), + (388, "SCG"), + (391, "JAM"), + (393, null), + (396, "USA"), + (399, "JPN"), + (403, "JOR"), + (411, "KIR"), + (420, "LAO"), + (423, "MYS"), + (426, "LSO"), + (427, "LVA"), + (431, "LBN"), + (434, "LBR"), + (438, "LBY"), + (440, "LIE"), + (442, "LTU"), + (445, "LUX"), + (447, "MAC"), + (449, "MKD"), + (450, "MDG"), + (452, "PRT"), + (455, "MYS"), + (458, "MWI"), + (461, "MDV"), + (464, "MLI"), + (467, "MLT"), + (472, "MNP"), + (474, "MAR"), + (476, "MHL"), + (477, "MTQ"), + (485, "MUS"), + (488, "MRT"), + (489, null), + (490, "UMI"), + (493, "MEX"), + (494, "MDA"), + (495, "MCO"), + (497, "MNG"), + (498, "MNE"), + (499, "FSM"), + (501, "MSR"), + (505, "MOZ"), + (507, "NAM"), + (508, "NRU"), + (511, "CXR"), + (517, "NPL"), + (521, "NIC"), + (525, "NER"), + (528, "NGA"), + (531, "NIU"), + (535, "NFK"), + (538, "NOR"), + (542, "NCL"), + (545, "PNG"), + (548, "NZL"), + (551, "VUT"), + (556, "OMN"), + (563, "UMI"), + (566, "UMI"), + (569, "UMI"), + (573, "NLD"), + (575, "PLW"), + (576, "PAK"), + (578, "PSE"), + (580, "PAN"), + (583, "PNG"), + (586, "PRY"), + (589, "PER"), + (593, "PCN"), + (599, "PYF"), + (603, "POL"), + (607, "PRT"), + (611, "PRI"), + (623, "KEN"), + (625, "KGZ"), + (628, "GBR"), + (640, "CAF"), + (647, "DOM"), + (660, "REU"), + (665, "ZWE"), + (670, "ROU"), + (675, "RWA"), + (676, "RUS"), + (677, "SLB"), + (678, "KNA"), + (685, "ESH"), + (687, "SLV"), + (690, "WSM"), + (691, "ASM"), + (693, "BLM"), + (695, "KNA"), + (697, "SMR"), + (698, null), + (699, "SXM"), + (700, "SPM"), + (705, "VCT"), + (710, "SHN"), + (715, "LCA"), + (720, "STP"), + (728, "SEN"), + (731, "SYC"), + (735, "SLE"), + (737, "SRB"), + (741, "SGP"), + (744, "SYR"), + (748, "SOM"), + (750, "LKA"), + (754, "SWZ"), + (755, "SJM"), + (756, "ZAF"), + (759, "SDN"), + (760, "SSD"), + (764, "SWE"), + (767, "CHE"), + (770, "SUR"), + (772, "TJK"), + (776, "THA"), + (780, "TZA"), + (781, "ATF"), + (782, "IOT"), + (783, "DJI"), + (785, null), + (786, "GBR"), + (788, "TCD"), + (790, "CSK"), + (791, "CZE"), + (795, "TLS"), + (800, "TGO"), + (805, "TKL"), + (810, "TON"), + (815, "TTO"), + (820, "TUN"), + (823, "TCA"), + (824, "TKM"), + (827, "TUR"), + (828, "TUV"), + (831, "UKR"), + (833, "UGA"), + (840, null), + (845, "URY"), + (847, "UZB"), + (848, "VAT"), + (850, "VEN"), + (858, "VNM"), + (863, "VGB"), + (866, "VIR"), + (870, "FJI"), + (873, "USA"), + (875, "WLF"), + (888, "COD"), + (890, "ZMB"), + (895, "PCZ"), + (990, null), + (994, null), + (995, null), + (997, null), + (998, null), + (999, null), + ] %} + when {{ column_name }} = '{{ old_code }}' then '{{ new_code }}' + {% endfor %} + else {{ column_name }} + end + +{% endmacro %} diff --git a/models/br_me_comex_stat/br_me_comex_stat__municipio_exportacao.sql b/models/br_me_comex_stat/br_me_comex_stat__municipio_exportacao.sql index 9a9b51a2..bc92dc8f 100644 --- a/models/br_me_comex_stat/br_me_comex_stat__municipio_exportacao.sql +++ b/models/br_me_comex_stat/br_me_comex_stat__municipio_exportacao.sql @@ -2,27 +2,35 @@ config( alias="municipio_exportacao", schema="br_me_comex_stat", - materialized="table", + materialized="incremental", partition_by={ "field": "ano", "data_type": "int64", - "range": {"start": 1997, "end": 2023, "interval": 1}, + "range": {"start": 1997, "end": 2025, "interval": 1}, }, cluster_by=["mes", "sigla_uf"], - labels={"project_id": "basedosdados", "tema": "economia"}, - post_hook=[ - 'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter ON {{this}} GRANT TO ("allUsers") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)', - 'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter ON {{this}} GRANT TO ("group:bd-pro@basedosdados.org", "group:sudo@basedosdados.org") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)', - ], + pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}", ) }} select safe_cast(ano as int64) ano, safe_cast(mes as int64) mes, - safe_cast(id_sh4 as string) id_sh4, + safe_cast(lpad(id_sh4, 4, '0') as string) id_sh4, safe_cast(id_pais as string) id_pais, - safe_cast(sigla_uf as string) sigla_uf, - safe_cast(id_municipio as string) id_municipio, + {{ transform_mdic_country_code("id_pais") }} as sigla_pais_iso3, + safe_cast(case when sigla_uf = 'ND' then null else sigla_uf end as string) sigla_uf, + safe_cast( + case + when id_municipio = '9300000' or id_municipio = '9999999' + then null + else id_municipio + end as string + ) id_municipio, safe_cast(peso_liquido_kg as int64) peso_liquido_kg, safe_cast(valor_fob_dolar as int64) valor_fob_dolar from `basedosdados-staging.br_me_comex_stat_staging.municipio_exportacao` as t +{% if is_incremental() %} + where + date(cast(ano as int64), cast(mes as int64), 1) + > (select max(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }}) +{% endif %} diff --git a/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql b/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql index 529e6349..0d9dca31 100644 --- a/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql +++ b/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql @@ -6,27 +6,30 @@ partition_by={ "field": "ano", "data_type": "int64", - "range": {"start": 1997, "end": 2023, "interval": 1}, + "range": {"start": 1997, "end": 2025, "interval": 1}, }, cluster_by=["mes", "sigla_uf"], pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}", - post_hook=[ - 'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter ON {{this}} GRANT TO ("allUsers") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)', - 'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter ON {{this}} GRANT TO ("group:bd-pro@basedosdados.org", "group:sudo@basedosdados.org") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)', - ], ) }} select safe_cast(ano as int64) ano, safe_cast(mes as int64) mes, - safe_cast(id_sh4 as string) id_sh4, + safe_cast(lpad(id_sh4, 4, '0') as string) id_sh4, safe_cast(id_pais as string) id_pais, - safe_cast(sigla_uf as string) sigla_uf, - safe_cast(id_municipio as string) id_municipio, + {{ transform_mdic_country_code("id_pais") }} as sigla_pais_iso3, + safe_cast(case when sigla_uf = 'ND' then null else sigla_uf end as string) sigla_uf, + safe_cast( + case + when id_municipio = '9300000' or id_municipio = '9999999' + then null + else id_municipio + end as string + ) id_municipio, safe_cast(peso_liquido_kg as int64) peso_liquido_kg, safe_cast(valor_fob_dolar as int64) valor_fob_dolar -from `basedosdados-staging.br_me_comex_stat_staging.municipio_importacao` as t +from `basedosdados-dev.br_me_comex_stat_staging.municipio_importacao` as t {% if is_incremental() %} where date(cast(ano as int64), cast(mes as int64), 1) diff --git a/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql b/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql index 158d0ded..80bf4694 100644 --- a/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql +++ b/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql @@ -6,30 +6,28 @@ partition_by={ "field": "ano", "data_type": "int64", - "range": {"start": 1997, "end": 2023, "interval": 1}, + "range": {"start": 1997, "end": 2025, "interval": 1}, }, cluster_by=["mes", "sigla_uf_ncm"], - labels={"project_id": "basedosdados", "tema": "economia"}, pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}", - post_hook=[ - 'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter ON {{this}} GRANT TO ("allUsers") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)', - 'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter ON {{this}} GRANT TO ("group:bd-pro@basedosdados.org", "group:sudo@basedosdados.org") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)', - ], ) }} select safe_cast(ano as int64) ano, safe_cast(mes as int64) mes, - safe_cast(id_ncm as string) id_ncm, + safe_cast(lpad(id_ncm, 8, "0") as string) id_ncm, safe_cast(id_unidade as string) id_unidade, safe_cast(id_pais as string) id_pais, - safe_cast(sigla_uf_ncm as string) sigla_uf_ncm, + {{ transform_mdic_country_code("id_pais") }} as sigla_pais_iso3, + safe_cast( + case when sigla_uf_ncm = 'ND' then null else sigla_uf_ncm end as string + ) sigla_uf_ncm, safe_cast(id_via as string) id_via, safe_cast(id_urf as string) id_urf, safe_cast(quantidade_estatistica as int64) quantidade_estatistica, safe_cast(peso_liquido_kg as int64) peso_liquido_kg, safe_cast(valor_fob_dolar as int64) valor_fob_dolar -from `basedosdados-staging.br_me_comex_stat_staging.ncm_exportacao` as t +from `basedosdados-dev.br_me_comex_stat_staging.ncm_exportacao` as t {% if is_incremental() %} where date(cast(ano as int64), cast(mes as int64), 1) diff --git a/models/br_me_comex_stat/br_me_comex_stat__ncm_importacao.sql b/models/br_me_comex_stat/br_me_comex_stat__ncm_importacao.sql index b95f8db6..ea646577 100644 --- a/models/br_me_comex_stat/br_me_comex_stat__ncm_importacao.sql +++ b/models/br_me_comex_stat/br_me_comex_stat__ncm_importacao.sql @@ -6,24 +6,22 @@ partition_by={ "field": "ano", "data_type": "int64", - "range": {"start": 1997, "end": 2023, "interval": 1}, + "range": {"start": 1997, "end": 2025, "interval": 1}, }, cluster_by=["mes", "sigla_uf_ncm"], - labels={"project_id": "basedosdados", "tema": "economia"}, pre_hook="DROP ALL ROW ACCESS POLICIES ON {{ this }}", - post_hook=[ - 'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter ON {{this}} GRANT TO ("allUsers") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)', - 'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter ON {{this}} GRANT TO ("group:bd-pro@basedosdados.org", "group:sudo@basedosdados.org") FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 6 OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) < 0)', - ], ) }} select safe_cast(ano as int64) ano, safe_cast(mes as int64) mes, - safe_cast(id_ncm as string) id_ncm, + safe_cast(lpad(id_ncm, 8, "0") as string) id_ncm, safe_cast(id_unidade as string) id_unidade, safe_cast(id_pais as string) id_pais, - safe_cast(sigla_uf_ncm as string) sigla_uf_ncm, + {{ transform_mdic_country_code("id_pais") }} as sigla_pais_iso3, + safe_cast( + case when sigla_uf_ncm = 'ND' then null else sigla_uf_ncm end as string + ) sigla_uf_ncm, safe_cast(id_via as string) id_via, safe_cast(id_urf as string) id_urf, safe_cast(quantidade_estatistica as float64) quantidade_estatistica, diff --git a/models/br_me_comex_stat/schema.yml b/models/br_me_comex_stat/schema.yml index 305abd44..bd3ed0af 100644 --- a/models/br_me_comex_stat/schema.yml +++ b/models/br_me_comex_stat/schema.yml @@ -4,6 +4,17 @@ models: - name: br_me_comex_stat__municipio_exportacao description: Base de dados detalhada por município da empresa exportadora e Posição do Sistema Harmonizado (SH4) + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - ano + - mes + - id_sh4 + - id_pais + - sigla_uf + - id_municipio + - not_null_proportion_multiple_columns: + at_least: 0.95 columns: - name: ano description: Ano @@ -11,12 +22,26 @@ models: description: Mês - name: id_sh4 description: ID Sistema Harmonizado + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__sistema_harmonizado') + field: id_sh4 - name: id_pais - description: ID País + description: ID do País + - name: sigla_pais_iso3 + description: Sigla ISO3 do País + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__municipio') + field: sigla_pais_iso3 - name: sigla_uf description: Sigla da Unidade da Federação - name: id_municipio description: ID Município - IBGE 7 Dígitos + tests: + - relationships: + to: ref('br_bd_diretorios_brasil__municipio') + field: id_municipio - name: peso_liquido_kg description: Peso Líquido - name: valor_fob_dolar @@ -24,6 +49,17 @@ models: - name: br_me_comex_stat__municipio_importacao description: Base de dados detalhada por município da empresa importadora e Posição do Sistema Harmonizado (SH4) + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - ano + - mes + - id_sh4 + - id_pais + - sigla_uf + - id_municipio + - not_null_proportion_multiple_columns: + at_least: 0.95 columns: - name: ano description: Ano @@ -31,12 +67,26 @@ models: description: Mês - name: id_sh4 description: ID Sistema Harmonizado + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__sistema_harmonizado') + field: id_sh4 - name: id_pais - description: ID País + description: ID do País + - name: sigla_pais_iso3 + description: Sigla ISO3 do País + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__municipio') + field: sigla_pais_iso3 - name: sigla_uf description: Sigla da Unidade da Federação - name: id_municipio description: ID Município - IBGE 7 Dígitos + tests: + - relationships: + to: ref('br_bd_diretorios_brasil__municipio') + field: id_municipio - name: peso_liquido_kg description: Peso Líquido - name: valor_fob_dolar @@ -44,6 +94,18 @@ models: - name: br_me_comex_stat__ncm_importacao description: Base de dados dos produtos importados pelo Brasil segundo a Nomenclatura Comum do Mercosul + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - ano + - mes + - sigla_uf_ncm + - id_ncm + - id_pais + - id_via + - id_urf + - not_null_proportion_multiple_columns: + at_least: 0.95 columns: - name: ano description: Ano @@ -51,12 +113,26 @@ models: description: Mês - name: id_ncm description: ID Produto - Nomenclatura Comum do Mercosul + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__nomenclatura_comum_mercosul') + field: id_ncm - name: id_unidade description: ID Unidade + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__nomenclatura_comum_mercosul') + field: id_unidade - name: id_pais - description: ID País + description: ID do País + - name: sigla_pais_iso3 + description: Sigla ISO3 do País + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__municipio') + field: sigla_pais_iso3 - name: sigla_uf_ncm - description: Sigla da Unidade da Federação - Nomenclatura Comum do Mercosu + description: Sigla da Unidade da Federação - Nomenclatura Comum do Mercosul - name: id_via description: ID Via de Transporte - name: id_urf @@ -72,8 +148,19 @@ models: - name: valor_seguro description: Valor do Seguro - name: br_me_comex_stat__ncm_exportacao - description: Base de dados detalhada de exportação por NCM. Os arquivos auxiliares - com todos os dicionários e valores de variáveis se encontram em https://storage.googleapis.com/basedosdados/auxiliary_files/br_me_comex_stat.zip. + description: Base de dados detalhada de exportação por NCM. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - ano + - mes + - sigla_uf_ncm + - id_ncm + - id_pais + - id_via + - id_urf + - not_null_proportion_multiple_columns: + at_least: 0.95 columns: - name: ano description: Ano @@ -81,10 +168,24 @@ models: description: Mês - name: id_ncm description: ID Produto - Nomenclatura Comum do Mercosul + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__nomenclatura_comum_mercosul') + field: id_ncm - name: id_unidade description: ID Unidade + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__nomenclatura_comum_mercosul') + field: id_unidade - name: id_pais - description: ID País + description: ID do País + - name: sigla_pais_iso3 + description: Sigla ISO3 do País + tests: + - relationships: + to: ref('br_bd_diretorios_mundo__municipio') + field: sigla_pais_iso3 - name: sigla_uf_ncm description: Sigla da Unidade da Federação - Nomenclatura Comum do Mercosu - name: id_via @@ -103,7 +204,7 @@ models: - name: id_tabela description: ID da tabela - name: coluna - description: Coluna + description: Nome da coluna - name: chave description: Chave - name: cobertura_temporal From bfe5e643160c8d914b36f9d496dd90b179f4f6b5 Mon Sep 17 00:00:00 2001 From: folhesgabriel Date: Wed, 24 Apr 2024 15:23:01 -0300 Subject: [PATCH 2/3] fix project name --- models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql b/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql index 80bf4694..82cb01dd 100644 --- a/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql +++ b/models/br_me_comex_stat/br_me_comex_stat__ncm_exportacao.sql @@ -27,7 +27,7 @@ select safe_cast(quantidade_estatistica as int64) quantidade_estatistica, safe_cast(peso_liquido_kg as int64) peso_liquido_kg, safe_cast(valor_fob_dolar as int64) valor_fob_dolar -from `basedosdados-dev.br_me_comex_stat_staging.ncm_exportacao` as t +from `basedosdados-staging.br_me_comex_stat_staging.ncm_exportacao` as t {% if is_incremental() %} where date(cast(ano as int64), cast(mes as int64), 1) From ab650959792572dd96229f2347c6092da19a4540 Mon Sep 17 00:00:00 2001 From: folhesgabriel Date: Wed, 24 Apr 2024 15:27:16 -0300 Subject: [PATCH 3/3] make requested chagnes --- .../br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql b/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql index 0d9dca31..189617bf 100644 --- a/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql +++ b/models/br_me_comex_stat/br_me_comex_stat__municipio_importacao.sql @@ -29,7 +29,7 @@ select ) id_municipio, safe_cast(peso_liquido_kg as int64) peso_liquido_kg, safe_cast(valor_fob_dolar as int64) valor_fob_dolar -from `basedosdados-dev.br_me_comex_stat_staging.municipio_importacao` as t +from `basedosdados-staging.br_me_comex_stat_staging.municipio_importacao` as t {% if is_incremental() %} where date(cast(ano as int64), cast(mes as int64), 1)