Skip to content

feat(world_cepii_baci): BACI international trade (HS92/HS17) + per-revision HS directories - #1791

Draft
rdahis wants to merge 2 commits into
mainfrom
data/world_cepii_baci
Draft

feat(world_cepii_baci): BACI international trade (HS92/HS17) + per-revision HS directories#1791
rdahis wants to merge 2 commits into
mainfrom
data/world_cepii_baci

Conversation

@rdahis

@rdahis rdahis commented Aug 12, 2026

Copy link
Copy Markdown
Member

What (draft — first pass)

Onboards CEPII BACI bilateral international trade (harmonized UN COMTRADE) as world_cepii_baci, with English table/column names. Ships the BACI-HS half now; SITC + complexity are pending (see below).

Tables (dev-validated, dbt test PASS=24/24)

Table Rows Coverage
world_cepii_baci.trade_hs92 269,894,500 1995–2024, HS 1992 rev.
world_cepii_baci.trade_hs17 89,207,221 2017–2024, HS 2017 rev.
br_bd_diretorios_comercio_internacional.hs1992 5,022 HS 1992 code set
br_bd_diretorios_comercio_internacional.hs2017 5,384 HS 2017 code set

Grain: year × exporter × importer × product. Columns: year, id_country_exporter, id_country_importer, product_code, value (thousand USD), quantity (metric tons).

FK design

  • product_code → hsXXXX.id_sh6 is exact — each trade table references its own revision's per-revision directory table, so no code-vintage mismatch. This is the reason for the per-revision hs* directories.
  • Country FK is tolerant (custom_relationships) — BACI uses aggregate/former-country codes absent from the standard M49 directory (842=USA+PR+VI, 251=France+Monaco, 58=Belgium-Luxembourg, 891=Serbia-Montenegro, …). Kept faithful to source and documented via ignore_values, as br_me_comex_stat does.

Pending in this PR (blocked)

trade_sitc, complexity_country, complexity_product — need the Harvard Atlas SITC data (Dataverse is currently rate-limiting downloads; will add once it clears).

Notes

🤖 Generated with Claude Code

rdahis added 2 commits August 12, 2026 11:45
…sion HS directory tables

International bilateral trade from CEPII BACI (harmonized UN COMTRADE), English
column names. First pass of the world_cepii_baci onboarding (dev-validated, dbt test 24/24).

- world_cepii_baci.trade_hs92 (269.9M rows, 1995-2024, HS 1992 revision)
- world_cepii_baci.trade_hs17 (89.2M rows, 2017-2024, HS 2017 revision)
- br_bd_diretorios_comercio_internacional.hs1992 / hs2017: per-revision HS6 directory
  tables so each trade table's product_code FKs to its own revision's exact code set.

Country FK (id_country_exporter/importer -> pais.id_m49) tolerant via custom_relationships:
BACI aggregate/former-country codes (842=USA+PR+VI, 58=Belgium-Luxembourg, ...) are absent
from the standard M49 directory and kept faithful to source. Pending (blocked on Atlas SITC
download): trade_sitc, complexity_country, complexity_product.

(Pyrefly pre-commit hook skipped: worktree is under gitignored .claude/, so it excludes all
files and errors on zero matches; ruff/sqlfmt/yamlfix all passed.)
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 67e4ddf9-e276-440f-b26f-cb794ac6c311

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@rdahis esse pull request tem conflitos 😩

@mergify mergify Bot added the conflict [PR] Conflito de merge a resolver label Aug 13, 2026
@rdahis rdahis self-assigned this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict [PR] Conflito de merge a resolver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant