This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| COPY live.order (order_id, user_name, order_status, order_date, order_approved_date, pickup_date, delivered_date, estimated_time_delivery) | |
| FROM 'C:\Users\William\Documents\DataScience\blibli\e-commerce-datsci-proj\data\raw\order_dataset.csv' | |
| DELIMITER ',' | |
| CSV HEADER; | |
| -- and so on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select user_name , customer_zip_code , customer_city , customer_state | |
| from ( | |
| SELECT | |
| DISTINCT *, | |
| RANK() over( | |
| PARTITION BY user_name | |
| ORDER BY customer_zip_code DESC, customer_state DESC , customer_city DESC | |
| ) as rank | |
| FROM | |
| live.user u |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| insert into staging.dim_product ( | |
| product_id, | |
| product_category, | |
| product_name_length, | |
| product_description_length, | |
| product_photos_qty, | |
| product_weight_g, | |
| product_length_cm, | |
| product_height_cm, | |
| product_width_cm, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Notes : Inserting updated data on product dimenstion table | |
| insert into staging.dim_product ( | |
| product_id, | |
| product_category, | |
| product_name_length, | |
| product_description_length, | |
| product_photos_qty, | |
| product_weight_g, | |
| product_length_cm, | |
| product_height_cm, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Fact table | |
| with stg_snapshot_user as ( | |
| select distinct | |
| user_name, | |
| count(order_id) as num_order | |
| from live."order" | |
| where order_status is not null and order_status not in ('canceled', 'unavailable') | |
| group by user_name | |
| ), stg_snapshot_spending as ( | |
| select distinct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Code that goes along with the Airflow tutorial located at: | |
| https://github.com/airbnb/airflow/blob/master/airflow/example_dags/tutorial.py | |
| """ | |
| from airflow import DAG | |
| from airflow.operators.python_operator import PythonOperator | |
| from airflow.operators.generic_transfer import GenericTransfer | |
| from airflow.contrib.hooks import FTPHook | |
| from airflow.hooks.mysql_hook import MySqlHook |