Skip to content

Commit e2b3d85

Browse files
tutorial lessons
0 parents  commit e2b3d85

19 files changed

+185
-0
lines changed

learn-dbt/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
target/
3+
dbt_modules/
4+
logs/

learn-dbt/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Welcome to your new dbt project!
2+
3+
### Using the starter project
4+
5+
Try running the following commands:
6+
- dbt run
7+
- dbt test
8+
9+
10+
### Resources:
11+
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/overview)
12+
- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers
13+
- Join the [chat](http://slack.getdbt.com/) on Slack for live discussions and support
14+
- Find [dbt events](https://events.getdbt.com) near you
15+
- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices

learn-dbt/analysis/.gitkeep

Whitespace-only changes.

learn-dbt/data/.gitkeep

Whitespace-only changes.

learn-dbt/dbt_project.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# Name your project! Project names should contain only lowercase characters
3+
# and underscores. A good package name should reflect your organization's
4+
# name or the intended use of these models
5+
name: 'jrtests_learn_dbt'
6+
version: '1.0.0'
7+
8+
# This setting configures which "profile" dbt uses for this project.
9+
profile: 'tutorial-jrtests-snowflake-db'
10+
11+
# These configurations specify where dbt should look for different types of files.
12+
# The `source-paths` config, for example, states that models in this project can be
13+
# found in the "models/" directory. You probably won't need to change these!
14+
source-paths: ["models"]
15+
analysis-paths: ["analysis"]
16+
test-paths: ["tests"]
17+
data-paths: ["data"]
18+
macro-paths: ["macros"]
19+
snapshot-paths: ["snapshots"]
20+
21+
target-path: "target" # directory which will store compiled SQL files
22+
clean-targets: # directories to be removed by `dbt clean`
23+
- "target"
24+
- "dbt_modules"
25+
26+
27+
# Configuring models
28+
# Full documentation: https://docs.getdbt.com/docs/configuring-models
29+
30+
# In this example config, we tell dbt to build all models in the example/ directory
31+
# as tables. These settings can be overridden in the individual model files
32+
# using the `{{ config(...) }}` macro.
33+
models:
34+
jrtests_learn_dbt:
35+
# Applies to all files under models/example/
36+
example:
37+
materialized: table
38+
vars:
39+
my_first_variable: True
40+
my_second_variable: 2020
41+
my_third_variable: 1

learn-dbt/macros/.gitkeep

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
select distinct
2+
o_orderdate,
3+
sum(o_totalprice) over (order by o_orderdate) as cumulative_sales
4+
5+
from "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."ORDERS"
6+
7+
order by o_orderdate
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{ config(materialized='incremental', unique_key='t_time') }}
2+
3+
select *
4+
from "SNOWFLAKE_SAMPLE_DATA"."TPCDS_SF10TCL"."TIME_DIM"
5+
where to_time(concat(T_HOUR::varchar, ':', T_MINUTE, ':', T_SECOND)) <= current_time
6+
7+
{% if is_incremental() %}
8+
and t_time > (select max(t_time) from {{ this }})
9+
{% endif %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
Welcome to your first dbt model!
4+
Did you know that you can also configure models directly within SQL files?
5+
This will override configurations stated in dbt_project.yml
6+
7+
Try changing "table" to "view" below
8+
*/
9+
{{ config(materialized='table', alias='first_model') }}
10+
11+
with source_data as (
12+
13+
select 1 as id
14+
union all
15+
select null as id
16+
union all
17+
select 3 as id
18+
19+
)
20+
21+
select *
22+
from source_data
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
-- Use the `ref` function to select from other models
3+
4+
select *
5+
from {{ ref('my_first_dbt_model') }}

0 commit comments

Comments
 (0)