-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dbt for data modeling #248
base: main
Are you sure you want to change the base?
Changes from 2 commits
1bcfcf3
37d191e
64fa5d5
1f0f27d
8546566
44d23c7
a358722
43c915d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
target/ | ||
dbt_packages/ | ||
logs/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Welcome to your new dbt project! | ||
|
||
### Using the starter project | ||
|
||
Try running the following commands: | ||
- dbt run | ||
- dbt test | ||
|
||
|
||
### Resources: | ||
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction) | ||
- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers | ||
- Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support | ||
- Find [dbt events](https://events.getdbt.com) near you | ||
- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
# Name your project! Project names should contain only lowercase characters | ||
# and underscores. A good package name should reflect your organization's | ||
# name or the intended use of these models | ||
name: '_dbt' | ||
version: '1.0.0' | ||
|
||
# This setting configures which "profile" dbt uses for this project. | ||
profile: '_dbt' | ||
|
||
# These configurations specify where dbt should look for different types of files. | ||
# The `model-paths` config, for example, states that models in this project can be | ||
# found in the "models/" directory. You probably won't need to change these! | ||
model-paths: ["models"] | ||
analysis-paths: ["analyses"] | ||
test-paths: ["tests"] | ||
seed-paths: ["seeds"] | ||
macro-paths: ["macros"] | ||
snapshot-paths: ["snapshots"] | ||
|
||
clean-targets: # directories to be removed by `dbt clean` | ||
- "target" | ||
- "dbt_packages" | ||
|
||
|
||
# Configuring models | ||
# Full documentation: https://docs.getdbt.com/docs/configuring-models | ||
|
||
# In this example config, we tell dbt to build all models in the example/ | ||
# directory as views. These settings can be overridden in the individual model | ||
# files using the `{{ config(...) }}` macro. | ||
models: | ||
_dbt: | ||
# Config indicated by + and applies to all files under models/example/ | ||
example: | ||
+materialized: view | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cette config permet à _dbt/models/intermediate/int_keywords_aggregated_by_days_and_channel.sql de devenir une vue matérialisée j'imagine ? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
/* | ||
Welcome to your first dbt model! | ||
Did you know that you can also configure models directly within SQL files? | ||
This will override configurations stated in dbt_project.yml | ||
Try changing "table" to "view" below | ||
*/ | ||
|
||
{{ config(materialized='table') }} | ||
|
||
with source_data as ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ici on mettrait la requête SQL qu'on souhaite transformer en vue, c'est bien ça ? |
||
|
||
select 1 as id | ||
union all | ||
select null as id | ||
|
||
) | ||
|
||
select * | ||
from source_data | ||
|
||
/* | ||
Uncomment the line below to remove records with null `id` values | ||
*/ | ||
|
||
-- where id is not null |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
-- Use the `ref` function to select from other models | ||
|
||
select * | ||
from {{ ref('my_first_dbt_model') }} | ||
where id = 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
version: 2 | ||
|
||
models: | ||
- name: my_first_dbt_model | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. j'imagine que c'est ici qu'on décrit le modèle Keywords |
||
description: "A starter dbt model" | ||
columns: | ||
- name: id | ||
description: "The primary key for this table" | ||
data_tests: | ||
- unique | ||
- not_null | ||
|
||
- name: my_second_dbt_model | ||
description: "A starter dbt model" | ||
columns: | ||
- name: id | ||
description: "The primary key for this table" | ||
data_tests: | ||
- unique | ||
- not_null |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
_dbt: | ||
target: dev | ||
outputs: | ||
dev: | ||
type: postgres | ||
host: postgres_db | ||
user: user | ||
password: password | ||
port: 5432 | ||
dbname: barometre | ||
schema: public | ||
threads: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pour la production, j'imagine qu'on devra ajouter
dbt run
dans le bash de lancement de l'image dockerhttps://github.com/dataforgoodfr/quotaclimat/blob/main/docker-entrypoint.sh#L5