From e51a7f8251ff4f895a500cdb21f8df880c4b8b08 Mon Sep 17 00:00:00 2001 From: ghannam omar Date: Sat, 23 Dec 2023 16:10:37 +0100 Subject: [PATCH 1/3] Creation du premier projet dbt vide --- answers/packages.yml | 6 +-- lessons/.gitignore | 4 ++ lessons/README.md | 15 ++++++++ lessons/analyses/.gitkeep | 0 lessons/dbt_project.yml | 37 +++++++++++++++++++ lessons/macros/.gitkeep | 0 lessons/models/example/my_first_dbt_model.sql | 27 ++++++++++++++ .../models/example/my_second_dbt_model.sql | 6 +++ lessons/models/example/schema.yml | 21 +++++++++++ lessons/seeds/.gitkeep | 0 lessons/snapshots/.gitkeep | 0 lessons/tests/.gitkeep | 0 12 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 lessons/.gitignore create mode 100644 lessons/README.md create mode 100644 lessons/analyses/.gitkeep create mode 100644 lessons/dbt_project.yml create mode 100644 lessons/macros/.gitkeep create mode 100644 lessons/models/example/my_first_dbt_model.sql create mode 100644 lessons/models/example/my_second_dbt_model.sql create mode 100644 lessons/models/example/schema.yml create mode 100644 lessons/seeds/.gitkeep create mode 100644 lessons/snapshots/.gitkeep create mode 100644 lessons/tests/.gitkeep diff --git a/answers/packages.yml b/answers/packages.yml index e091e30bab..ec1158dd13 100644 --- a/answers/packages.yml +++ b/answers/packages.yml @@ -1,9 +1,9 @@ packages: - package: dbt-labs/dbt_utils - version: 1.0.0 + version: 1.1.1 - package: calogica/dbt_expectations - version: [">=0.8.0", "<0.9.0"] + version: [">=0.8.0", "<2.0.0"] - package: dbt-labs/codegen - version: 0.9.0 + version: 0.12.1 diff --git a/lessons/.gitignore b/lessons/.gitignore new file mode 100644 index 0000000000..49f147cb98 --- /dev/null +++ b/lessons/.gitignore @@ -0,0 +1,4 @@ + +target/ +dbt_packages/ +logs/ diff --git a/lessons/README.md b/lessons/README.md new file mode 100644 index 0000000000..7874ac842b --- /dev/null +++ b/lessons/README.md @@ -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 diff --git a/lessons/analyses/.gitkeep b/lessons/analyses/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lessons/dbt_project.yml b/lessons/dbt_project.yml new file mode 100644 index 0000000000..f31bb25204 --- /dev/null +++ b/lessons/dbt_project.yml @@ -0,0 +1,37 @@ + +# 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: 'lessons' +version: '1.0.0' +config-version: 2 + +# This setting configures which "profile" dbt uses for this project. +profile: 'lessons' + +# 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: + lessons: + # Config indicated by + and applies to all files under models/example/ + example: + +materialized: view diff --git a/lessons/macros/.gitkeep b/lessons/macros/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lessons/models/example/my_first_dbt_model.sql b/lessons/models/example/my_first_dbt_model.sql new file mode 100644 index 0000000000..f31a12d948 --- /dev/null +++ b/lessons/models/example/my_first_dbt_model.sql @@ -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 ( + + 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 diff --git a/lessons/models/example/my_second_dbt_model.sql b/lessons/models/example/my_second_dbt_model.sql new file mode 100644 index 0000000000..c91f8793a5 --- /dev/null +++ b/lessons/models/example/my_second_dbt_model.sql @@ -0,0 +1,6 @@ + +-- Use the `ref` function to select from other models + +select * +from {{ ref('my_first_dbt_model') }} +where id = 1 diff --git a/lessons/models/example/schema.yml b/lessons/models/example/schema.yml new file mode 100644 index 0000000000..2a53081715 --- /dev/null +++ b/lessons/models/example/schema.yml @@ -0,0 +1,21 @@ + +version: 2 + +models: + - name: my_first_dbt_model + description: "A starter dbt model" + columns: + - name: id + description: "The primary key for this table" + tests: + - unique + - not_null + + - name: my_second_dbt_model + description: "A starter dbt model" + columns: + - name: id + description: "The primary key for this table" + tests: + - unique + - not_null diff --git a/lessons/seeds/.gitkeep b/lessons/seeds/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lessons/snapshots/.gitkeep b/lessons/snapshots/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lessons/tests/.gitkeep b/lessons/tests/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 0adaf2a739d4f410707df2d85581a370a3296dc4 Mon Sep 17 00:00:00 2001 From: ghannam omar Date: Sat, 23 Dec 2023 16:32:04 +0100 Subject: [PATCH 2/3] 2 new empty lines --- lessons/models/example/my_second_dbt_model.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lessons/models/example/my_second_dbt_model.sql b/lessons/models/example/my_second_dbt_model.sql index c91f8793a5..ca53d2c31a 100644 --- a/lessons/models/example/my_second_dbt_model.sql +++ b/lessons/models/example/my_second_dbt_model.sql @@ -4,3 +4,5 @@ select * from {{ ref('my_first_dbt_model') }} where id = 1 + + From aac6c5724e678e4b7257743f755ff81d99dc84b5 Mon Sep 17 00:00:00 2001 From: ghannam omar Date: Sun, 24 Dec 2023 15:14:52 +0100 Subject: [PATCH 3/3] Supression des modeles exemples --- .vscode/settings.json | 3 +++ answers/package-lock.yml | 10 +++++++ lessons/models/example/my_first_dbt_model.sql | 27 ------------------- .../models/example/my_second_dbt_model.sql | 8 ------ lessons/models/example/schema.yml | 21 --------------- 5 files changed, 13 insertions(+), 56 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 answers/package-lock.yml delete mode 100644 lessons/models/example/my_first_dbt_model.sql delete mode 100644 lessons/models/example/my_second_dbt_model.sql delete mode 100644 lessons/models/example/schema.yml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..6e25ef6fa2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dbt.queryLimit": 500 +} \ No newline at end of file diff --git a/answers/package-lock.yml b/answers/package-lock.yml new file mode 100644 index 0000000000..30af95ca39 --- /dev/null +++ b/answers/package-lock.yml @@ -0,0 +1,10 @@ +packages: +- package: dbt-labs/dbt_utils + version: 1.1.1 +- package: calogica/dbt_expectations + version: 0.10.1 +- package: dbt-labs/codegen + version: 0.12.1 +- package: calogica/dbt_date + version: 0.10.0 +sha1_hash: 1f6859dfa92277b8f9d2c4a68de169e692440983 diff --git a/lessons/models/example/my_first_dbt_model.sql b/lessons/models/example/my_first_dbt_model.sql deleted file mode 100644 index f31a12d948..0000000000 --- a/lessons/models/example/my_first_dbt_model.sql +++ /dev/null @@ -1,27 +0,0 @@ - -/* - 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 ( - - 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 diff --git a/lessons/models/example/my_second_dbt_model.sql b/lessons/models/example/my_second_dbt_model.sql deleted file mode 100644 index ca53d2c31a..0000000000 --- a/lessons/models/example/my_second_dbt_model.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- Use the `ref` function to select from other models - -select * -from {{ ref('my_first_dbt_model') }} -where id = 1 - - diff --git a/lessons/models/example/schema.yml b/lessons/models/example/schema.yml deleted file mode 100644 index 2a53081715..0000000000 --- a/lessons/models/example/schema.yml +++ /dev/null @@ -1,21 +0,0 @@ - -version: 2 - -models: - - name: my_first_dbt_model - description: "A starter dbt model" - columns: - - name: id - description: "The primary key for this table" - tests: - - unique - - not_null - - - name: my_second_dbt_model - description: "A starter dbt model" - columns: - - name: id - description: "The primary key for this table" - tests: - - unique - - not_null