Rapport Lab 2: Data Warehouse ETL
đ RĂ©sumĂ© ExĂ©cutif
â Construction rĂ©ussie dâun entrepĂŽt de donnĂ©es avec architecture Star Schema.
Statistiques:
- 6 tables de dimension
- 1 table de faits
- 20 événements
- 3 formats dâexport
- 100% portes de qualité validées
đ Architecture Finale
SchĂ©ma en Ătoile
dim_utilisateur
â
â
dim_date â fact_events â dim_produit
dim_age â â dim_categorie
dim_marque
Dimensions
dim_utilisateur (10 rows)
- user_key (PK)
- user_id (FK métier)
- gender
- birthdate
- generation (Traditionalists/Boomers/GenX/Millennials/GenZ)
dim_age (10 rows)
- age_key (PK)
- age_band (<18, 18-24, 25-34, âŠ, 85-94, unknown)
- min_age, max_age
dim_marque (5 rows)
- brand_key (PK)
- brand_code
- brand_desc
dim_categorie (5 rows)
- category_key (PK)
- category_code
- category_desc
dim_produit (10 rows)
- product_key (PK)
- product_id
- product_desc
- brand_key (FK)
- category_key (FK)
dim_date (4 rows)
- date_key (PK) [YYYYMMDD]
- date
- year, month, day
- day_of_week, day_name
- is_weekend
- week_of_year, month_name
- quarter
Table de Faits
fact_events (20 rows)
| Colonne | Type | FK |
|---|---|---|
| date_key | INT | â |
| utilisateur_key | INT | â |
| age_key | INT | â |
| produit_key | INT | â |
| marque_key | INT | â |
| categorie_key | INT | â |
| session_id | STRING | - |
| event_time | TIMESTAMP | - |
| event_type | STRING | - |
| price | DOUBLE | - |
â Portes de QualitĂ©
Porte 1: Comptage Non-ZĂ©ro â
Condition: COUNT(fact_events) > 0
Résultat: 20 > 0
Statut: â
PASS
Porte 2: Taux de NullitĂ© â
date_key: 0.00% †5.00% â
utilisateur_key: 0.00% †5.00% â
produit_key: 0.00% †5.00% â
event_type: 0.00% †1.00% â
price: 0.00% †20.00% â
Porte 3: IntĂ©gritĂ© RĂ©fĂ©rentielle â
FK date_key â dim_date: 0 manquants â
FK utilisateur_key â dim_utilisateur: 0 manquants â
FK produit_key â dim_produit: 0 manquants â
đ Compression & Performance
Comparaison Tailles de Fichiers
| Format | Taille | Ratio vs Parquet |
|---|---|---|
| CSV brut | 0.0010 MB | 2.0x |
| CSV Snappy | 0.0008 MB | 1.6x |
| Parquet | 0.0005 MB | 1.0x |
Conclusion: Parquet est 2x plus compact que CSV!
đ ïž Transformations AppliquĂ©es
Nettoyage events
â
Suppression timestamps NULL
â
Suppression session_id NULL
â
Suppression product_id NULL
â
Filtre prix négatifs
â
Filtre dates futures
â
Validation event_types
â
Suppression prix outliers (>100x moyenne)Enrichissement Dimensions
dim_utilisateur:
+ Calcul year_of_birth
+ Classification génération (basée année naissance)
+ Génération user_key (dense_rank)
dim_produit:
+ JOIN product_name (descriptions)
+ JOIN dim_marque (brand_key)
+ JOIN dim_categorie (categorie_key)
+ Génération product_keyConstruction fact_events
events_clean
â JOIN session_bridge (session_id â utilisateur_id)
â JOIN prod_lkp (produit_id â clĂ©s)
â JOIN date_lkp (event_date â date_key)
â JOIN utilisateur_lkp (utilisateur_id â utilisateur_key)
â CALCUL age_on_event (F.months_between)
â JOIN dim_age (age_on_event â age_key)đ Statistiques DonnĂ©es
Comptages CSV Sources
user.csv: 10 lignes
session.csv: 10 lignes
product.csv: 10 lignes
product_name.csv: 5 lignes
events.csv: 20 lignes
brand.csv: 5 lignes
category.csv: 5 lignes
AprĂšs Nettoyage
events_clean: 20 lignes
- 0 suppressions timestamp NULL
- 0 suppressions session_id NULL
- 0 suppressions product_id NULL
- 0 suppressions prix négatifs
- 0 suppressions dates futures
AprĂšs Star Schema
fact_events: 20 lignes (100% conservés)
- Toutes dimensions liées
- Aucune porte de qualité échouée
âïž Configuration Spark
Spark Version: 4.0.1
Master: local[*]
Driver Memory: 8g
Shuffle Partitions: 200
Adaptive Query Execution: Enabled
Compression: snappyđ Concepts MaĂźtrisĂ©s
â Star Schema design â Dimension vs Fact tables â Surrogate keys (dense_rank) â Data quality gates â Parquet vs CSV â Window functions (OVER, PARTITION BY) â Multi-table joins (LEFT joins) â Date handling â Price outlier detection â Generation classification
đ Cellules Notebook
| # | Titre | Lignes |
|---|---|---|
| 0 | Imports & Setup | 12 |
| 1 | Spark Init | 17 |
| 2 | Load CSV | 25 |
| 3 | dim_utilisateur | 18 |
| 4 | dim_age | 18 |
| 5 | dim_marque | 11 |
| 6 | dim_categorie | 11 |
| 7 | dim_produit | 32 |
| 8 | dim_date | 26 |
| 9 | Résumé dimensions | 18 |
| 10 | Clean events | 23 |
| 11 | Analyse prix | 28 |
| 12 | Lookup tables | 16 |
| 13 | fact_events | 52 |
| 14 | Affichage fact_events | 13 |
| 15 | Portes qualité | 56 |
| 16 | Exports | 29 |
| 17 | Comparaison sizes | 35 |
| 18 | Spark plans | 12 |
| 19 | Résumé final | 40 |
Total: 507 lignes de code PySpark
đ RĂ©sultats Finaux
- â Star schema complet et validĂ©
- â 6 dimensions de haute qualitĂ©
- â 1 table de faits avec 20 Ă©vĂ©nements
- â 3 formats dâexport (CSV, Snappy, Parquet)
- â 100% portes de qualitĂ© validĂ©es
- â Compression optimale (Parquet 2x plus petit)
- â Aucun data quality issue
- â IntĂ©gritĂ© rĂ©fĂ©rentielle 100%
đ RĂ©fĂ©rences
- Apache Spark Documentation: https://spark.apache.org/docs/latest/
- PySpark API: https://spark.apache.org/docs/latest/api/python/
- Star Schema: https://en.wikipedia.org/wiki/Star_schema
Rapport généré le: Décembre 8, 2025 Auteur: Badr TAJINI Institution: ESIEE Paris