DBT: Gold Tanzania Trade Coffee 2020
File location: s3://trase-storage/tanzania/trade/2020/gold/gold_tanzania_trade_coffee_2020.parquet
DBT model name: gold_tanzania_trade_coffee_2020
Explore on Metabase: Full table; summary statistics
DBT details
- Lineage
-
Dbt path:
trase_production.main_tanzania_coffee.gold_tanzania_trade_coffee_2020 -
Containing yaml link: trase/data_pipeline/models/tanzania/trade/2020/gold/_schema.yml
-
Model file: trase/data_pipeline/models/tanzania/trade/2020/gold/gold_tanzania_trade_coffee_2020.py
-
Tags:
gold,tanzania,coffee,trade,2020,diet-trase-coffee
Description
....
Details
| Column | Type | Description |
|---|---|---|
year |
INTEGER |
|
exporter_label |
VARCHAR |
|
exporter_node_id |
INTEGER |
|
exporter_group_name |
VARCHAR |
|
country_of_destination |
VARCHAR |
|
mass_tonnes |
DOUBLE |
|
fob |
DOUBLE |
|
importer_label |
VARCHAR |
|
port_of_export_label |
VARCHAR |
|
hs6 |
VARCHAR |
Models / Seeds
source.trase_duckdb.source_tanzania_trade.original_tanzania_comtrade_2020source.trase_duckdb.source_tanzania_trade.original_tanzania_exports_2020
Sources
['source_tanzania_trade', 'original_tanzania_comtrade_2020']['source_tanzania_trade', 'original_tanzania_exports_2020']
No called script or script source not found.
# gold_tanzania_trade_coffee_2020
from trase.data.tanzania.trade.y2020.tanzania_coffee_2020 import (
get_tanzania_coffee_2020,
)
def model(dbt, session):
dbt.config(materialized="external")
session.execute("INSTALL spatial; LOAD spatial;")
# Declaring the sources so they appear in the documentation / lineage
comtrade_data = dbt.source(
"source_tanzania_trade", "original_tanzania_comtrade_2020"
)
trade_data = dbt.source("source_tanzania_trade", "original_tanzania_exports_2020")
df = get_tanzania_coffee_2020()
export_data = session.sql(
f"""
WITH final_fields AS (
SELECT
YEAR::INT AS year,
EXPORTER_NAME_ORIGINAL AS exporter_label,
EXPORTER_ID AS exporter_node_id,
EXPORTER_GROUP AS exporter_group_name,
COUNTRY_DESTINATION AS country_of_destination,
NET_WEIGHT/1000 AS mass_tonnes,
FOB_VALUE_IN_USD AS fob,
BUYER_NAME AS importer_label,
PORT_NAME AS port_of_export_label,
HS_CODE AS hs6
FROM df
)
SELECT * FROM final_fields
"""
).arrow()
return export_data