Skip to content

AntoineGiraud/dbt_bixi_opendata

Repository files navigation

Bixi's OpenData Modelisation

Here is a dbt-core project that loads & transform bixi OpenData thanks to DuckDB 🦆🚀

Viz' exploration

After the pandemic, Montrealers realy went back to bixi 🥳

Explore Montréal bixi rentals with Power BI

Data sources

Bixi Rentals OpenData (link)

  • 🚲 Rentals V1 : from 2014 to 2021

    for station info, join to station yearly file with station_code

  • Stations V1 : from 2014 to 2021

    1 station code per year

  • 🚲 Rentals V2 : from 2022 to 2024+

    start/end station info on each rentals
    -> 2.7 times heavier .csv 1.4Gb -> 0.5Gb
    -> 2.3 times heavier .parquet 250Mb -> 106Mb

GIS referential

  • 🧭 Municipal sectors : from the OD 2013 survey (cf. donnees quebec)

GBFS scrapping - station live status (one day)

GBFS means General Bikeshare Feed Specification, it's a standardized data feed for shared mobility system availability (cf. Github > MobilityData/gbfs)

💡 Max Halford launch a web scrapping on 76 bikeshares around the globe at summer 2023. (cf. it's bike sharing forecasting training set article) Montréal was added at the end of spring.

Schema/DB steps :

  • raw : raw tables loaded as is from .csv
  • stg : intermediate tables
  • dtm : tables ready for analytics & reporting use
  • reports : aggregations for viz' use

dbt docs catalog & lineage (url)

dbt lineage

dbt colibri column lineage view (url)

colibri column lineage

if needed : 🖼 DBeaver MLD

Loading

DuckDB realy shines by it's speed & local OLAP capabilities 😎

Here is 🚲 v1 rentals (2014 - 2021) load & offload to .parquet

  • .csv is 4.5 times heavier than .parquet
  • .json is 2.7 times heavier than .csv

bixi rentals loading with DuckDB 🚀🦆

Resources

Outils

  • dbt-core enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
    dbt-core
  • git gestion de versions
  • VS Code éditeur de code
  • uv extremely fast Python package & project manager, written in Rust.
  • DuckDB analytical in-process SQL database
  • DBeaver Database Management Tool
  • dbt colibri Column level lineage & documentation to your dbt projects

Se former à dbt & l'Analytics Engineering

Commandes dbt importantes

Commande Rôle
dbt ls Liste les modèles
dbt parse Vérifie syntaxe et validité
dbt compile Génère SQL à partir des modèles
dbt run Exécute les modèles (sans tests)
dbt test Lance uniquement les tests
dbt build Exécute modèles + tests
dbt build -s +stg_commande+ Construit stg_commande + parent & enfants
dbt retry Reprendre depuis la dernière erreur (run, build, test, compile, docs...)
dbt docs generate Génère la documentation
dbt docs serve Lance un serveur web pour explorer doc & lineage
colibri generate Générer le lineage à la colonne

Bonnes pratiques nommage des commit

Norme conventional commit : <type>(optional scope): <description>

type usage exemple 💡
feat nouvelle fonctionnalité visible ajout d’auth Google
fix correction de bug pagination API
docs changement de documentation mise à jour README
style formatage sans impact logique indentation
refactor amélioration interne sans ajout ni bugfix simplification parsing
test ajout/modif de tests tests unitaires user
chore maintenance/config sans impact fonctionnel mise à jour dépendances, script CI

Installation

Récupérer les outils

  • git ou winget install --id Git.Git -e --source winget
    • Dire à git qui vous êtes
      git config --global user.name "PrenomNom"
      git config --global user.email votresuper@email.fr
  • uv ou powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  • DuckDB ou winget install DuckDB.cli
  • DBeaver ou windows store
  • VS Code ou windows store

Clone & setup local du projet

  • git clone https://github.com/AntoineGiraud/dbt_bixi_opendata.git
  • cd dbt_bixi_opendata se déplacer dans le dossier récupéré avec git
  • uv sync
    • télécharge python si non présent
    • initialise un environnement virtuel python (venv) si non présent
    • télécharge les dépendances / extensions python
  • .venv/Scripts/activate.ps1 (unix source .venv/bin/activate)
    rendre dbt disponible dans le terminal
  • code . ouvrir dans VS Code le répertoire courrant
  • S'assurer que pre-commit est installé (cf. 📹 vidéo intro - 5min)
    • uv tool install pre-commit --with pre-commit-uv : installer pre-commit comme outil python global (option)
    • uv run pre-commit install : initialiser le hook git
      • juste avec ça, sur les prochains fichiers édités, ruff sera lancé automatiquement
    • uv run pre-commit run --all-files : pour traiter TOUS les fichiers

About

dbt-duckdb 🦆 model & transformation on Montreal's bixi bikeshare opendata (rentals & GBFS) 🚲

Topics

Resources

Stars

Watchers

Forks

Contributors