· 5 years ago · Feb 25, 2020, 07:52 PM
1
2
3# This configuration file specifies information about your package
4# that dbt needs in order to build your models. This file is _required_
5
6#########################
7#### PROJECT DETAILS ####
8#########################
9
10# name: Required. This is the name used to reference your package in the configs
11# below. Package names must only contain letters and underscores
12name: 'jaffle_shop'
13
14# version: Required. This indicates the current version of your package and
15# should conform to semantic versioning. The field is currently unused
16version: '0.0.1'
17
18# require-dbt-version: Optional. This is used to validate that your project is
19# compatible with your dbt version
20require-dbt-version: [">=0.14.0", "<0.15.0"]
21
22####################################
23#### CONNECTION CONFIGURATIONS #####
24####################################
25
26# profile: Required. This config specifies which profile dbt should use to
27# connect to your data warehouse. The provided value must exist in the
28# profiles.yml file.
29profile: "jaffle_shop"
30
31
32##################################
33#### FILE PATH CONFIGURATIONS ####
34##################################
35
36# The following configs specify directories that dbt uses to operate. All
37# paths are specified relative to the path of dbt_project.yml.
38
39# ALL FILE PATH CONFIGURATIONS ARE OPTIONAL, the default values are listed below.
40
41# source-paths: Specify which path(s) dbt should look in to find models. Model
42# are.sql files. Model and source schema files (.yml files) should also be
43# included in this path
44source-paths: ["models"]
45
46# analysis-paths: Specify which path(s) dbt should look in to find analytical
47# queries. These queries are compiled, but not executed, by dbt.
48analysis-paths: ["analysis"]
49
50# test-paths: Specify which path(s) dbt should look in to find data test
51# definitions.
52test-paths: ["tests"]
53
54# data-paths: Specify which path(s) dbt should look in to find CSV files.
55# Running `dbt seed` will load these CSVs as tables in your warehouse.
56data-paths: ["data"]
57
58# macro-paths: Specify which path(s) dbt should look in to find macros. These
59# macros will be globally available to all models in your project.
60macro-paths: ["macros"]
61
62# snapshot-paths: Specify with path(s) dbt should look in to finds napshots.
63# Running `dbt snapshot` will run these snapshots.
64snapshot-paths: ["snapshots"]
65
66# target-path: Specify which path dbt should write compiled SQL to.
67target-path: "target"
68
69# log-path: Specify which path dbt should write debug logs to.
70log-path: "logs"
71
72# modules-path: Specify which path dbt should use for storing and finding modules.
73modules-path: "dbt_modules"
74
75# clean-targets: Specify which path(s) should be removed by the clean task. Run
76# `dbt clean` to delete these directories
77clean-targets: ["target", "dbt_modules"]
78
79
80
81#################################
82#### RESOURCE CONFIGURATIONS ####
83#################################
84
85# The following section contains configurations that define how your resources
86# are instantiated by dbt. You can configure `models`, and `seeds` from here.
87# You can configure resources from both your own project, and installed
88# packages included as dependencies.
89#
90# Options are specified on a per-package, per-directory, and per-model basis.
91# The configs are inherited, so configs applied to a package can be overridden
92# for directories and models contained within that package.
93#
94# The configuration structure within a package should mirror the directory
95# structure within that package. The example configs provided below are based
96# on the following directory structure.
97#
98# dbt_project.yml
99# models/
100# ├── adwords
101# │ └── adwords_ads.sql
102# └── snowplow
103# ├── base
104# │ └── snowplow_events.sql
105# └── snowplow_sessions.sql
106
107models:
108 enabled: true # configs defined here are applied to _all_ packages
109 materialized: view # but can be overridden in more specific configs below
110
111 # pre- and post- hooks can be defined anywhere within the model hierarchy.
112 # when defined at the root level (as they are here), they apply to all models
113 # in all packages. These hooks are compiled into the model SQL and run either
114 # before or after the model is materializated.
115 pre-hook:
116 - "insert into audit (model, state, time) values ('{{ this.name }}', 'start', getdate())"
117
118 post-hook:
119 - "grant select on {{this}} to user_1"
120 - "insert into audit (model, state, time) values ('{{ this.name }}', 'end', getdate())"
121
122 # This is the configuration for the models in your local package. The value
123 # for the `name` key (defined above) should be used here
124 jaffle_shop:
125 # Applies to all SQL files found under ./models/adwords/
126 adwords:
127 enabled: false
128 # Applies to the specific model ./models/adwords/adwords_ads.sql
129 adwords_ads:
130 enabled: true
131 materialized: table
132
133 # Applies to all SQL files found under ./models/snowplow/
134 snowplow:
135 # Applies to all SQL files found under ./models/snowplow/base
136 base:
137 # Applies to model ./models/snowplow/base/snowplow_events.sql
138 snowplow_events:
139 materialized: table
140 sort: ['timestamp', 'userid']
141 sort_type: interleaved
142 dist: 'userid'
143
144 # Applies to model ./models/snowplow/snowplow_sessions.sql
145 snowplow_sessions:
146 materialized: incremental
147 sql_where: "created_at > (select max(created_at) from {{ this }})"
148 unique_key: "id"
149 sort: "timestamp"
150 dist: "user_id"
151
152seeds:
153 enabled: true
154 pre-hook:
155 - "insert into audit (model, state, time) values ('{{ this.name }}', 'start', getdate())"
156
157 post-hook:
158 - "grant select on {{ this }} to user_1"
159 - "insert into audit (model, state, time) values ('{{ this.name }}', 'end', getdate())"
160
161snapshots:
162 enabled: true
163 tags: ["daily"]
164 jaffle_shop:
165 target_database: "raw"
166 transient: false
167
168###################
169#### RUN HOOKS ####
170###################
171# Like the pre- and post- hooks above, the on-run-start and on-run-end configs
172# make it possible to run SQL at the very beginning, and very end of a dbt run.
173on-run-start:
174 - "create table if not exists audit (model text, state text, time timestamp)"
175
176on-run-end:
177 - 'grant usage on schema "{{ target.schema }}" to db_reader'
178 - 'grant select on all tables in schema "{{ target.schema }}" to db_reader'