diff --git a/dbt_project/models/ANALYTICS/location_stats.sql b/dbt_project/models/ANALYTICS/location_stats.sql new file mode 100644 index 00000000..a546a9bf --- /dev/null +++ b/dbt_project/models/ANALYTICS/location_stats.sql @@ -0,0 +1,7 @@ +select + order_date, + state, + count(*) as n_orders, + sum(order_total) as total_revenue +from {{ ref("orders_augmented") }} +group by 1, 2 diff --git a/dbt_project/models/CLEANED/orders_cleaned.sql b/dbt_project/models/CLEANED/orders_cleaned.sql index c200e626..39803556 100644 --- a/dbt_project/models/CLEANED/orders_cleaned.sql +++ b/dbt_project/models/CLEANED/orders_cleaned.sql @@ -6,6 +6,7 @@ select sku, dt, cast(dt as datetime) as order_date, + date_trunc('month', order_date) as order_month, quantity * purchase_price as order_total from {{ source("raw_data", "orders") }} {% if is_incremental() %} diff --git a/hooli_data_eng/assets/dbt_assets.py b/hooli_data_eng/assets/dbt_assets.py index 17c4f5e2..74f66ff1 100644 --- a/hooli_data_eng/assets/dbt_assets.py +++ b/hooli_data_eng/assets/dbt_assets.py @@ -144,7 +144,7 @@ def _process_partitioned_dbt_assets(context: AssetExecutionContext, dbt: DbtCliR @dbt_assets( manifest=DBT_MANIFEST, project=dbt_project, - select="orders_cleaned users_cleaned orders_augmented", + select="orders_cleaned users_cleaned orders_augmented location_stats", partitions_def=daily_partitions, dagster_dbt_translator=CustomDagsterDbtTranslator( settings=DagsterDbtTranslatorSettings( diff --git a/hooli_data_eng/resources/api.py b/hooli_data_eng/resources/api.py index 881383c8..807260a8 100644 --- a/hooli_data_eng/resources/api.py +++ b/hooli_data_eng/resources/api.py @@ -33,7 +33,7 @@ def get_orders(self, datetime_to_process): # random order data returned, see utils.py json = random_data( - extra_columns={"order_id": str, "quantity": int, "purchase_price": float, "sku": str}, + extra_columns={"order_id": str, "order_desc": str, "quantity": int, "purchase_price": float, "sku": str}, n = 10, filter_date=datetime_to_process ).to_json()